Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm install doesn't create node_modules directory

I am trying to do a homework for a mongodb uni course. They gave us some files, instructions are:

run npm install mongodb then node app.js

for some reason npm install does not create a node_modules directory but I don't see any build errors:

mongo-uni/hw1-2$ npm install mongodb npm WARN package.json [email protected] path is also the name of a node core module. npm http GET https://registry.npmjs.org/mongodb npm http 304 https://registry.npmjs.org/mongodb npm http GET https://registry.npmjs.org/bson/0.2.5 npm http GET https://registry.npmjs.org/kerberos/0.0.3 npm http 304 https://registry.npmjs.org/kerberos/0.0.3 npm http 304 https://registry.npmjs.org/bson/0.2.5  > [email protected] install /home/jasonshark/node_modules/mongodb/node_modules/kerberos > (node-gyp rebuild 2> builderror.log) || (exit 0)  make: Entering directory `/home/jasonshark/node_modules/mongodb/node_modules/kerberos/build'   SOLINK_MODULE(target) Release/obj.target/kerberos.node   SOLINK_MODULE(target) Release/obj.target/kerberos.node: Finished   COPY Release/kerberos.node make: Leaving directory `/home/jasonshark/node_modules/mongodb/node_modules/kerberos/build'  > [email protected] install /home/jasonshark/node_modules/mongodb/node_modules/bson > (node-gyp rebuild 2> builderror.log) || (exit 0)  make: Entering directory `/home/jasonshark/node_modules/mongodb/node_modules/bson/build'   CXX(target) Release/obj.target/bson/ext/bson.o make: Leaving directory `/home/jasonshark/node_modules/mongodb/node_modules/bson/build' [email protected] ../../../node_modules/mongodb ├── [email protected] └── [email protected] mongo-uni/hw1-2$ node app.js Failed to load c++ bson extension, using pure JS version 'No document found' 
like image 664
Connor Leech Avatar asked Jan 21 '14 06:01

Connor Leech


People also ask

Does npm install create a node_modules folder?

js project, npm automatically creates the node_modules folder to store the modules needed for your project and the package-lock. json file that you examined earlier. The node_modules folder contains every installed dependency for your project.

Why npm install is not working?

On Windows, the cause of this error could be that a PATH or system variable is not correctly set. The error can also occur if you do not have npm or Node. js installed, have an outdated version, or have permission issues.

Which command create node modules folder?

Create a package. js module, run npm init : For scoped modules, run npm init --scope=@scope-name. For unscoped modules, run npm init.


2 Answers

npm init

It is all you need. It will create the package.json file on the fly for you.

like image 65
CESCO Avatar answered Sep 19 '22 22:09

CESCO


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,

  1. Create project directory: mkdir <project-name>
  2. Switch to: cd <project-name>
  3. Do: npm init This will create package.json file at current path
  4. Open package.json & fill it something like below

    {     "name": "project-name",     "version": "project-version",     "dependencies": {         "mongodb": "*"     } } 
  5. Now do : npm install OR npm update

Now it will create node_modules directory under folder 'project-name' you created.

like image 39
Piyush Sagar Avatar answered Sep 19 '22 22:09

Piyush Sagar