npm install doesn't create node_modules directory
npm init
It is all you need. It will create the package.json file on the fly for you.
NPM has created a node_modules directory at '/home/jasonshark/' path.
From your question it looks like you wanted node_modules to be created in the current directory.
For that,
- Create project directory:
mkdir <project-name>
- Switch to:
cd <project-name>
- Do:
npm init
This will create package.json file at current path Open package.json & fill it something like below
{ "name": "project-name", "version": "project-version", "dependencies": { "mongodb": "*" } }
Now do :
npm install
ORnpm update
Now it will create node_modules directory under folder 'project-name' you created.
If you have a package-lock.json
file, you may have to delete that file then run npm i
. That worked for me