NPM Install Error:Unexpected end of JSON input while parsing near '…nt-webpack-plugin“:”0'

前端 未结 30 1855
孤街浪徒
孤街浪徒 2020-11-22 10:20

When Creating a new Angular 5 project:

node version: 8.9.2

npm version: 5.5.1

My Command is

npm install -g @angular/cli
相关标签:
30条回答
  • 2020-11-22 11:10

    If npm cache clean --force doesn't resolve the issue, try deleting the ~/.npm directory (*nix/macOS). This is the directory where node stores its cache, locks, logs, global packages (unless you're using nvm), and modules installed via npx.

    First, backup your current ~./npm directory:

    mv ~/.npm ~/.npm-backup
    

    Now try running your npm command again. This will create a new ~/.npm directory. If the issue is resolved, you can safely remove you backup. Before doing so, you may want to review the global packages installed in your ~/.npm-backup directory so you can reinstall them using npm i -g [package].

    rm -rf ~/.npm-backup
    

    If the issue is not resolved, you can restore your backup:

    rm -rf ~/.npm
    mv ~/.npm-backup ~/.npm
    

    Careful with those rm commands, folks!

    0 讨论(0)
  • 2020-11-22 11:11

    ERROR: npm ERR! Unexpected end of JSON input while parsing near '...ore-js":"3.0.0-beta.1

    This occurs when installing the expo CLI globally, This works for me!

    npm cache clean --force
    
    0 讨论(0)
  • 2020-11-22 11:13

    This solved it for me:

    Open Windows Powershell as admin

    npm cache clean --force
    npm install -g @angular/cli
    

    https://devblogs.microsoft.com/premier-developer/getting-started-with-node-js-angular-and-visual-studio-code/

    0 讨论(0)
  • 2020-11-22 11:13

    This command alone solved my problem:

    npm cache clean --force
    

    Also you should make sure you are using the correct version of node.

    Using nvm to manage the node version:

    nvm list; # check your local versions;
    nvm install 10.10.0; # install a new remote version;
    nvm alias default 10.10.0; # set the 10.10.0 as the default node version, but you have to restart the terminal to make it take effect;
    
    0 讨论(0)
  • 2020-11-22 11:13

    Just faced the issue of Unexpected end of JSON input while parsing near.. while adding the 'radium' package in my React App. As a matter of fact, I am facing this issue even when trying to update the NPM to the latest version.

    Anyways, NPM didn't work after clearing the cache and it also won't update to the latest version right now but adding the package via Yarn did the trick for me.

    So, if you are in a hurry to solve this issue but you are not able to, then give yarn a try instead of npm.

    Happy Coding!

    Update

    After trying few things finally sudo npm cache clean --force worked for me.

    This can be a temporary glitch in your network or with something else in the npm registry.

    0 讨论(0)
  • 2020-11-22 11:14

    My case - Windows 7 (had nothing better at the needed moment). Helped me the following:

    1. Deleting everything from C:\Users\username\AppData\Roaming\npm-cache

    AND

    1. Deleting package-lock.json
    0 讨论(0)
提交回复
热议问题