javascript - Why is npm install not installing packages into node_modules folder? - Stack Overflow

When I npm install package, npm says that it successfully installed the package, but when I look for it

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?

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?

Share Improve this question asked Apr 12, 2020 at 14:39 Daniel WilczynskiDaniel Wilczynski 511 gold badge1 silver badge3 bronze badges 6
  • 1 are you using vscode terminal to install the package? – Furqan Aziz Commented Apr 12, 2020 at 14:41
  • Do you have a package.json in the directory you're installing from? – Aplet123 Commented Apr 12, 2020 at 14:41
  • I am using powershell in vscode terminal, and my package.json is in the same directory as /node_modules – Daniel Wilczynski Commented Apr 12, 2020 at 14:43
  • If you require the package after installing it, does it error? – Aplet123 Commented Apr 12, 2020 at 14:43
  • Aplet123 what do you mean by require? – Daniel Wilczynski Commented Apr 12, 2020 at 14:49
 |  Show 1 more ment

3 Answers 3

Reset to default 0

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.

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

step 2) npm install.

The above mands 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 mands 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.

Here's what worked for me:

  1. Find file named .npmrc (for me it was in C:/Users/username)
  2. Open it and if you have location=global ment it out with #
  3. In your project folder run npm ci

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744943850a4602495.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信