2

I'm using latest npm, on a mac. I've got a strange problem: if I want to install some package locally on a folder, I'm forced to npm init it. In other words, if I simply npm install [package name], it will install globally (in my /User/npm-modules folder), and thus the onnly way to install locally is to init the folder. So basically, the opposite it should normally do. Why? Any idea?

Luca Reghellin
  • 7,426
  • 12
  • 73
  • 118

2 Answers2

7

npm init creates package.json file in your current project directory. npm packages will install locally when you have package.json set up by using the command npm i PACKAGE-NAME.

Usama Tahir
  • 1,707
  • 3
  • 15
  • 30
4

Yes, if you want to install package localy, you need to create package.json file. This is what npm init will do and then you can install packages

Piosek
  • 220
  • 1
  • 4
  • 15