Npm install cannot find module 'semver'

后端 未结 26 1511
南方客
南方客 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:50

    In my case on macOS(10.13.6), when I executed the following command

    npm install -g react-native-cli
    

    I got this error

    Error: Cannot find module 'semver'
        at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
        at Function.Module._load (internal/modules/cjs/loader.js:562:25)
        at Module.require (internal/modules/cjs/loader.js:690:17)
        at require (internal/modules/cjs/helpers.js:25:18)
        at Object. (/usr/local/lib/node_modules/npm/lib/utils/unsupported.js:2:14)
        at Module._compile (internal/modules/cjs/loader.js:776:30)
        at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
        at Module.load (internal/modules/cjs/loader.js:653:32)
        at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
        at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    

    The error got resolved after executing the command

    yarn global add npm
    

    proposed by @Ashoor

提交回复
热议问题