Npm install cannot find module 'semver'

后端 未结 26 1328
南方客
南方客 2020-11-29 15:29

I can\'t use npm install using the command prompt in NodeJS. I\'m getting these errors when running npm install:

module.js:339
             


        
相关标签:
26条回答
  • 2020-11-29 15:44

    For me, this happened after I installed yarn globally. To resolve this issue, install npm using yarn and done.

    yarn global add npm
    
    0 讨论(0)
  • 2020-11-29 15:45

    As noted by anonymous(?) at DeveloperReference.com, the steps below resolved the "cannot find module 'semver'" for me when running npm -install:

    *"I followed These steps and it solved my issue uninstall Node.js

    1. Remove the content of the following folders
      • C:\Users\ {username} \AppData\Roaming\npm-cache
      • C:\Users\ {username\ \AppData\Roaming\npm
    2. C:\Program Files\nodejs Then again install Node from https://nodejs.org/en/"*

    https://html.developreference.com/article/12253101/Cannot+find+module+%27semver%27+When+installing+Npm

    | |
    0 讨论(0)
  • 2020-11-29 15:46

    Having just encountered this on Arch Linux 4.13.3, I solved the issue by simply reinstalling semver:

    pacman -S semver
    
    0 讨论(0)
  • 2020-11-29 15:46

    For me, it happened while upgrading to gulp 4 from gulp 3 in my project. So, when I run "gulp watch" command, it was throwing me same error.

    It's probably due to version mismatch as compared to my globally installed gulp.

    So, either upgrading gulp with "-g" global flag would help, or else I followed this below

    However, I used "./node_modules/.bin/gulp watch" in my project. This ensures that all the dependencies that gulp needs are taken from node_modules only.

    0 讨论(0)
  • 2020-11-29 15:48

    I had the same issue installing on AWS Linux. I had to install it with sudo. So to get around this I followed step 3 from this article (making sure to get the latest version of node)

    https://www.hostingadvice.com/how-to/update-node-js-latest-version/

    wget https://nodejs.org/dist/vx.x.x/node-vx.x.x-linux-x64.tar.xz
    tar -C /home/aUser/node --strip-components 1 -xJf node-vx.x.x-linux.x64.tar.xz
    

    But installed it to the user's home directory /home/aUser/node. Then added that path to my PATH.

    export PATH=/home/aUser/node/bin:$PATH

    After that I was able to do an npm install with no issues.

    0 讨论(0)
  • 2020-11-29 15:49

    I had this too, after running brew install yarn yesterday. At least, everything was fine up until then.

    I ran rm -rf node_modules and tried to reinstall, but no npm command was working.

    In the end I took the rather simple step of reinstalling Node via the official Node installer for Mac OS X.

    https://nodejs.org/en/download/

    Everything is fine now. Just went back to the directory, ran npm install and it's done the trick.

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