npm install doesn't create node_modules directory

后端 未结 8 1928
故里飘歌
故里飘歌 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:24

    If you have a package-lock.json file, you may have to delete that file then run npm i. That worked for me

    0 讨论(0)
  • 2020-12-05 13:27

    I ran into this trying to integrate React Native into an existing swift project using cocoapods. The FB docs (at time of writing) did not specify that npm install react-native wouldn't work without first having a package.json file. Per the RN docs set your entry point: (index.js) as index.ios.js

    0 讨论(0)
  • 2020-12-05 13:31

    See @Cesco's answer: npm init is really all you need


    I was having the same issue - running npm install somePackage was not generating a node_modules dir.

    I created a package.json file at the root, which contained a simple JSON obj:

    {
        "name": "please-work"
    }
    

    On the next npm install the node_modules directory appeared.

    0 讨论(0)
  • 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 <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.

    0 讨论(0)
  • 2020-12-05 13:39

    npm init

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

    0 讨论(0)
  • 2020-12-05 13:39

    my problem was to copy the whole source files contains .idea directory and my webstorm terminal commands were run on the original directory of the source
    I delete the .idea directory and it worked fine

    0 讨论(0)
提交回复
热议问题