Reputation: 8125
So I navigated to my project directory and run npm install scrollama intersection-observer
. It installed the files on my HOME/node-modules instead of the project folder. During installation there were warnings, though:
npm WARN saveError ENOENT: no such file or directory, open '[my-home]/package.json'
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open '[my-home]/package.json'
npm WARN [my-user] No description
npm WARN [my-user] No repository field.
npm WARN [my-user] No README data
npm WARN [my-user] No license field.
So why did it installed globally (or, in my home instead of my project folder)?
Upvotes: 0
Views: 191
Reputation: 1080
You are not using npm init
. npm init will initialize your node project and will make a package.json file. package.json file will store the information about the project such as project name, version, description and also the dependencies you download.
In your case there is no package.json file, because of this your packages are been installed to the home directory instead of current directory.
Also you can also use parameters like -g to install package globally (to the home directory) without any parameter, node will install the package in the current directory by default.
Installing locally: you can use the package inside your project. Installing globally: you can use the package everywhere. Commands like nodemon are installed globally because you want to use these in every project.
Upvotes: 2
Reputation: 138537
Because your folder is not a valid npm install location as it could not find the package.json
. to create that, just run:
npm init
Upvotes: 2