npm install doesn't create node_modules directory

后端 未结 8 2091
故里飘歌
故里飘歌 2020-12-05 13:07

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<

8条回答
  •  感情败类
    2020-12-05 13:36

    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
    2. Switch to: cd
    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.

提交回复
热议问题