NPM doesn't install module dependencies

前端 未结 16 1723
深忆病人
深忆病人 2020-12-02 06:39

This is my package.json for the module that I\'m including in the parent project:

{
  \"version\": \"0.0.1\",
  \"name\": \"module-name\",
  \"d         


        
相关标签:
16条回答
  • 2020-12-02 06:44

    happens with old node version. use latest version of node like this:

    $ nvm use 8.0
    $ rm -rf node_modules
    $ npm install
    $ npm i somemodule

    edit: also make sure you save.
    eg: npm install yourmoduleName --save

    0 讨论(0)
  • 2020-12-02 06:44

    I had the same problem. But on the same machine one project had good package.json, where all my dependencies are successfully installed. And in another project my package.json dependencies were not installed no matter what i do. I just copied the package.json and pasted into that another project. And it worked! The difference i have found was only empty line at the start of file. Dont know or it influences anything, maybe some other problem. But the problem was only the package.json file.

    0 讨论(0)
  • 2020-12-02 06:45

    Also check that your package name is correctly accepted:

    WRONG:

    {
        "name":"My Awesome Package"
    }
    


    CORRECT

    {
        "name": "my-awesome-package-name"
    }
    
    0 讨论(0)
  • 2020-12-02 06:46

    I was receiving this error when I installed a clean Node dev environment on windows.

    To fix this, I went into my new project directory (that I just scaffolded with yo angular) and typed in two commands:

    npm install -g grunt --save-dev

    That will install the local grunt dependencies to your project. Next:

    npm install

    That will ensure all your (new) project dependencies are installed.

    Tada!

    0 讨论(0)
  • 2020-12-02 06:48

    Just in case anyone is suffering from this predicament and happens to make the same asanine mistake that I did, here is what it was in my case. After banging my head against the wall for an hour, I realized that I had my json incorrectly nested, and the key "dependencies" was inside of the key "repository".
    Needless to say, no errors were evident, and no modules were installed.

    0 讨论(0)
  • 2020-12-02 06:50

    Worth to mention to make sure your dependencies should be in the dependencies part of your package.json (as opposed to devDependencies).

    My issue was basically the same as OP:

    • installing a private repo (Let's call it repo1) via "module-name": "git+ssh://git@myserver:user/my-repo-name.git" in other repo(Let's call it repo2),
    • in repo2's node_modules, one package dependency from repo1 wasn't there.
    • My silly mistake!.. repo1 was listing that dependency in devDependencies instead of dependencies
    • Move the dependency in my repo1's package.json from devDependencies to dependencies
    • In my repo2, I removed my node_modules and package-lock.json, did npm install, an voilà!... dependency was there!
    0 讨论(0)
提交回复
热议问题