Why is npm install not installing packages into /node_modules folder?

Viewed 4422

When I npm install package, npm says that it successfully installed the package, but when I look for it in the node_modules folder, the package is not in the folder. When I npm install -g package, the package gets installed into the global /node_modules folder, so I have to drag the package from the global folder to the local folder.

Why is npm install not installing into my local /node_modules folder?

2 Answers

step 1) rm -rf ./node_modules from your root directory.

step 2) npm install.

The above commands first deletes your node_modules and then reinstalls all the packages that are found inside your package.json.

This is the same problem I was facing, both the above commands resolved the problem in my case.

If the above solution does not work in your case :

The problem is :

Data is not being fetched from the package.json, you must check whether you have written the correct statement or not inside your package.json.

There are a few things you can do to resolve this problem, as mentioned here.

First, try deleting your package-lock.json file. If you run npm install or npm i after that it should generate a brand new installation with no reference to an existing package-lock.json file.

If that doesn't work, try deleting your node_modules directory in your project. Then run npm install or npm i.

If THAT doesn't work, you should try deleting both the node_modules directory AND the package-lock.json. Then run npm install or npm i. This should resolve the issue.

Related