npm keeps installing globally

823 views javascript

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?

answered question

2 Answers


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

posted this

npm init creates package.json file in your current project directory. npm packages will install locally when you have package.json set up.

posted this

Have an answer?


Please login first before posting an answer.