Npm Install Failing

npm install error from the terminal

Running just "npm install" will look for dependencies listed in your package.json. The error you're getting says that you don't have a package.json file set up (or you're in the wrong directory).

If you're trying to install a specific package, you should use 'npm install {package name}'. See here for more info about the command.

Otherwise, you'll need to create a package.json file for your dependencies or go to the right directory and then run 'npm install'.

Error while running the command npm install

The issue is that npm can't find the package.json file.

Normally, this is a very simple problem that can be fixed easily.


1. Not in the directory of package.json

If you already have the package.json file, then you need to make sure that you are in the directory in which the file is in.

To see if the file is in your directory, run the dir command.

$ dir

If you aren't in the directory in which package.json is in, then navigate to that directory.


2. Creation of package.json

Another issue that can occur is that you haven't yet created a package.json file.

To do this, run the following command.

$ npm init

However, if you don't want to answer the questions from running that command, run the following.

$ npm init -y

This will initialise the package.json file in your directory.


Edit: If you try to run npm install, and you get the following error:

npm ERR! code ERESOLVE - unable to resolve dependency tree

That means that you have a dependency conflict. To fix this issue, run the command with the following flag.

$ npm install --legacy-peer-deps

This will resolve any incompatible packages (e.g. one package needs a lower version then what you currently have).


After you have done either of these solutions, then running the command below should work successfully.

$ npm install

How to solve npm install error “npm ERR! code 1”

If your Node.js version is very recent, try downgrading. The stable version 14.16.1 worked.

npm Install fails error Build failed with error code: 1

If your Node version is very recent, try downgrading. Stable version 14.16.1 worked.

Unable to resolve dependency tree error when installing npm packages

This is not related to an HTTP proxy.

You have dependency conflict (incorrect and potentially broken dependency) as it says, so try to run the command with --force, or --legacy-peer-deps. If it doesn't take effect, the temporary solution is using prior versions of the Node.js (downgrading the Node.js version) as it causes this kind of errors to happen sometimes.

Update based on the OP's update:

As you see, it fires the following error:

No matching version found for @angular/http@^9.1.4.

Take a look at angular/http page. Note that the latest version for that deprecated package is 7.2.16 while you request an upper version (e.g., ^9.1.4)! So, try to check the project dependencies and follow the raised errors in order to solve the problem.



Related Topics



Leave a reply



Submit