Angular error: The object prototype can only be an Object or null, not undefined

My project was functional until I decided to install ExcelJs (npm install --save exceljs) and things took a turn for the worse.

I started encountering errors such as

Cannot read property ‘Minus’ of undefined
and
Cannot find module 'postcss-value-something'
. Resolving these errors by installing missing parts using npm i , led me to yet another error -
TypeError: Object prototype may only be an Object or null: undefined
.

In an attempt to restore order, I removed ExcelJs from my project but unfortunately, the issues persisted.

The detailed error message is as follows:

    at setPrototypeOf (<anonymous>)
    at Object.__extends (F:\Honeycomb\Honey\Varroa\node_modules\@angular\compiler-cli\node_modules\tslib\tslib.js:68:9)
    ...

The contents of my package.json reveal various dependencies that might be causing conflicts within the project.

 "dependencies": {
   // List of dependencies
  },
  "devDependencies": {
    // List of devDependencies
  }

All signs point towards the cli/compiler cli version or even typescript being the culprits. However, finding specific information on the compatibility between versions has been challenging.

If you have any insights or guidance on resolving these issues, it would be greatly appreciated.

Answer №1

Wow, it looks like your Angular package versions are completely out of whack! How did your compiler-cli end up at 10.0.2 while your HTTP is only at 7.2.16? That's quite the mismatch! The best way to bring everything back in line is by using ng update @angular/cli, ng update @angular/core, and ng update @angular/material.

By following these steps, you can upgrade all your Angular packages to version 10 and hopefully handle any necessary migrations smoothly. It's crucial for all packages starting with @angular to have the same major version. Mixing versions like v7, v8, and v10 will only lead to confusion.

If updating through the CLI doesn't work, you might want to consider the following alternative steps:

  • Back up your source code located under src, as well as any other files you may want to save such as package.json to check for non-Angular packages dependencies.
  • Delete the entire project folder.
  • Upgrade your global @angular/cli by running
    npm install -g @angular/cli@latest
    .
  • Create a new project using ng new xxx.
  • Transfer your src files to the newly created project, excluding main.ts, polyfills.ts, and the tsconfig files due to significant changes in the latest Angular CLI version.
  • (Optional) Update any custom changes made in the non-copied files like package.json.

Going forward, always utilize ng update to keep all your Angular modules up to date, ensuring necessary code migrations are handled properly.

Just a quick note, using the ^ symbol will update the minor version of your installed package when doing npm update. For more information, check out this link here.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Is it possible to choose the inverse of a user-defined type in Angular?

Is it possible to retrieve the opposite of a specified custom type within a variable using Typescript? For example, if I define a type like this: type Result = 'table' | 'grid'; Then any variable with the type Result can only be assign ...

Obtaining child component references in Angular using @ViewChildren

Currently, I am generating several ModuleItemComponents by utilizing the following Angular syntax: <div #moduleItems *ngFor="let module of seriesItem.modules; let i = index"> <app-module-item [videoModule]="module" >< ...

What is the best way to manage various Firebase Cloud Function API endpoints for different environments, such as DEV and PROD?

I am currently developing an Angular application hosted on Firebase. I am facing a question regarding the best approach to handle the same application being deployed in two different environments (DEV and PROD), each associated with a separate Firebase pr ...

What is the best way to overload a function based on the shape of the argument object in

If I am looking to verify the length of a string in two different ways (either fixed or within a specific range), I can do so using the following examples: /* Fixed check */ check('abc', {length: 1}); // false check('abc', {length: 3}) ...

The Glyphicon is failing to display on the template

I recently set up bootstrap in my VS Code environment and linked it to the styles.css file with this code snippet: @import '~bootstrap/dist/css/bootstrap.css'; Upon further inspection of the package.json, I confirmed that "bootstrap": "^4.1.1" ...

Is there a way to turn off NPM package restore in Visual Studio 2015?

Every time I launch a project in Visual Studio 2015 that has a package.json file, an npm install process starts automatically. This causes Visual Studio to become unresponsive until the installation is finished. Is there a way for me to disable this autom ...

Crafting a personalized arrow for sorting headers in Angular Material

Currently working on an Angular 5 project and I'm looking to implement a custom sort icon in the header. The goal is to achieve a similar effect to this example, without using the default arrow. I attempted to modify the CSS styles, but it wasn' ...

Using Typescript for-loop to extract information from a JSON array

I'm currently developing a project in Angular 8 that involves utilizing an API with a JSON Array. Here is a snippet of the data: "success":true, "data":{ "summary":{ "total":606, "confirmedCasesIndian":563, "con ...

react.js function that returns 'undefined'

Having trouble with my class function that returns undefined when I try to use the return value. Main.js: let db = new Database() let username = db.get() return( //returns undefined <p>{username}</p> ) database.js: class Database { [... ...

How to Customize Bootstrap Colors Globally in Angular 4 Using Code

I am interested in developing a dynamic coloring system using Angular. I have set up a service with four predefined strings: success, info, warning, and danger, each assigned default color codes. My goal is to inject this service at the root of my applicat ...

What is the significance of the underscore prefix in package.json properties?

Can you explain the significance of prefixing properties with an underscore in package.json? What is the reason behind using underscores in this context? "_from": "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="6b190e0a081 ...

Issues with Angular2 http.get() returning 404 errors consistently

I'm encountering an issue while attempting to load dummy JSON data from a file using angular2 http.get method. It appears that the method is unable to retrieve the data, consistently returning a 404 status code for resource not available. Below is the ...

What could be the reason for the failure of the docker-compose volume binding while building? Is it obligatory to always COPY the essential build files?

I am utilizing a basic node image configuration in my Docker Compose setup. Currently, I have to run npm install after the container build process is completed. However, I would like to streamline this by incorporating it into the build itself. Unfortunate ...

Integrating Vimeo videos into Angular applications

I am attempting to stream videos using URLs in my Angular application. Every time I try, I encounter the following error: Access to XMLHttpRequest at 'https://player.vimeo.com/video/548582212?badge=0&amp;autopause=0&amp;player_id=0&amp;ap ...

Ways to manage an rxjs observable reaction that may potentially have no data?

Currently, I am working with Angular2 and Ionic2 using typescript and have a requirement to manage responses from the backend service. The response may either be empty with http status 200 or it could be a json object containing an error message property ...

How can scripts communicate with one another through passing arguments?

"scripts": { "dev": "npm run development", "development": "run-something", .... When invoking my script, I use the following command: npm run dev This is a convenient shortcut that executes the standard command npm-run-development. Is there ...

Tips for verifying the connections between an Angular application and Azure Function (negotiate) when integrating with Azure SignalR Service

I'm working on an angular application that is authenticated with Azure AD, connecting to an Azure Function (negotiate) which then communicates with Azure SignalR service using specific keys. I am looking for guidance on how to authenticate requests ma ...

Error message displaying that the argument for the onChange state in a jhipster react form is not assignable as type '{ [x: number]: any; }'

Just diving into the world of React and encountering a bit of a struggle with jsx when it comes to setting state in a form that contains two fields and triggers an ajax call to store a json object (response data) in the state's field3. The code I curr ...

Can Envs in Bit be linked together?

My React environment is set up at this link: . It is configured with the following dependencies: { /** * standardize your component dependencies. * @see https://bit.dev/docs/react-env/dependencies **/ "policy": { // peer and dev ...

Is it necessary to provide initialState in React Context when using useState in TypeScript, even if it serves no purpose?

Using Context to share the value and setValue from the useState hook. The code provided below is functional, but it may be considered overly verbose. As a TypeScript beginner, I am wondering if there is a more elegant approach to achieve the same functiona ...