Can't install any package with node npm

前端 未结 16 1968
一向
一向 2020-12-02 13:12

I\'m trying to install some node packages through npm, but it won\'t go. I\'ve already tried to install/unistall/update node, but nothing seems to work.

I\'m using u

相关标签:
16条回答
  • 2020-12-02 13:41

    For future reference, this can also happen if npm is down. That's how I found this question. Wish the first npm task was a server status check so there was a clearer error message.

    0 讨论(0)
  • 2020-12-02 13:42

    If you're unlucky enough to be switching back and forth from a network behind a proxy and a network NOT behind a proxy, you may have forgotten that your NPM config is set to expect a proxy.

    For me, I had to open up ~/.npmrc and comment out my proxy settings (while at home) and vice versa while at work (behind the proxy).

    0 讨论(0)
  • 2020-12-02 13:42

    Adding a -g to the end of my install fixed this for me. ex: npm install uglify-js -g

    0 讨论(0)
  • 2020-12-02 13:43

    This means the npm command is getting an HTML document instead of whatever format it is looking for. In my case, I was using sinopia. When I no longer wanted to use it, I accidentally used this command to reset the registry:

    npm config set registry https://www.npmjs.com/
    

    which was wrong, and it should have been the command already mentioned here. Read this if none of the answers solve this problem, and you can probably figure out where the incorrect URL is present and clear it off, and set the registry to the correct URL:

    npm config set registry https://registry.npmjs.org
    
    0 讨论(0)
  • 2020-12-02 13:46

    Try:

    npm install underscore
    

    :)

    There is no unserscore package in npm registry.

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

    This is to do with SSL for some reason. If you set the registry to be plain http then it should work. You can set it to always be this via:

    npm config set registry http://registry.npmjs.org/
    

    or as jairaj said, you can supply it in the command line.

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