NPM Cannot read property '0' of undefined

前端 未结 11 638
你的背包
你的背包 2021-01-03 17:52

After updated Node (upto v8.6.0) and npm (upto v5.5.1) I cannot execute command npm install. After npm install I\'ve error message:

npm ERR! Can         


        
相关标签:
11条回答
  • 2021-01-03 18:38

    I've made some tests:

    nodejs@8.6.0 npm@5.5.1 - I have trouble and the test fails

    nvm use 8.5.0
    

    nodejs@8.5.0 npm@5.5.1 - I have trouble and the test fails

    nvm use 8.4.0
    

    nodejs@8.4.0 npm@5.5.1 - I have trouble and the test fails

    npm install npm@^5 -g
    

    nodejs@8.4.0 npm@5.4.2 - I have trouble and the test fails

    nvm use 8.6.0
    npm install npm@^4 -g
    

    nodejs@8.6.0 npm@4.6.1 - no trouble, this fixes it.

    0 讨论(0)
  • 2021-01-03 18:39

    Do 2 steps bellow (Window):

    rm -rf ./node_modules to remove node folder

    rm package-lock.json to remove package-lock.json file

    then npm install to re-install the node modules

    0 讨论(0)
  • 2021-01-03 18:41

    Just download and install latest Yarn which is also a node package manager, developed by facebook, but has a much better dependency management. Also update your node cli (optional).

    And then, install your dependencies using yarn:

    yarn install
    

    or

    yarn // short version of yarn install
    

    No errors!

    You can continue to use npm after you have installed all dependencies with yarn or continue with yarn....it's your choice.

    0 讨论(0)
  • 2021-01-03 18:42

    I bumped into this issue using nvs (Node Version Switcher - https://github.com/jasongin/nvs) node@10.15.3 and npm@6.9.0. The reason was a local package I had linked with npm link. The solution was to remove that folder.

    0 讨论(0)
  • 2021-01-03 18:43

    For me (npm@6.9.0) solved the issue by deleting node_modules and performing npm install, but without removing package.json.lock file.

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