NPM not found

The bug description

Unknown cause:

  1. Maybe he used onen stable, upgrade node;
  2. It could also be usednpm i -g npmTo upgrade the NPM;
  3. It is also possible that the MAC has quietly upgraded the system.

In short, the results spiralled out of control: NPM not found

try

Curve 1:

Change. ZSHRC PATH, Google out of the solution, did not understand, did not solve the problem.

Curve 2:

Because the error contained ZSH, we took a detour, deleted ZSH, changed the shell environment, and still reported an error. Because that’s not the reason. ZSHRC: uninstall_oh_my_zsh: uninstall_oh_my_zsh: uninstall_oh_my_zsh: uninstall_oh_my_zsh: uninstall_oh_my_zsh:

  1. cat /etc/shells/bin/sh
  2. chsh -s /bin/bashZSH is still present in the error, because terminal was not closed and restarted.
  3. Restart terminal. Goose, these are not the problem, so the problem remains. Without ZSH, still

Enable the NVM

Difference between NVM and N

One more thing, why NVM:

NVM is an external shell script independent of Node/NPM, so the n command is more limited than the NVM command. Solution:

  1. NVM is installed remotelyThe curl - o - https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash2) Install the old version of NodeNVM install v8.93) which node

    Before installing NVM:

    4) Cut to your old versionNVM use v8.9

test

harvest

  1. nodeAs the operating environment of the whole project, it is also dependent on NPM. There is a matching relationship between the versions of the two, and neither of them can be arbitrarily modified, especiallynpm; (????? If this is indeed the cause of the problem, it is a gain; So this is not necessarily true)
  2. nvmAs anodeManagement or becausenYes, I’ll use it laternvm!
  3. Macos upgrades should also be careful: because

/usr/local can no longer be chown’d in High Sierra.

Instead use sudo chown -R $(whoami) $(brew --prefix)/*

Afterword.

Module build failed: Error: Missing binding… node_modules/node-sass/vendor/darwin-x64-57/binding.node

NPM Rebuild node-sass The project is running… 😔

Second, the NPM ERR! Unexpected end of JSON input while parsing near ‘… Ace – event “:” ^ 1.0.0, “” ‘

The bug description

At this point, NPM I keeps reporting errors and error logs cannot find valid information. NPM package path error:

To solve

Tried to find the NPM package path, but no root problem was found;

solve

Run NPM cache clean –force. NPM I has no previous error. Explore what NPM caching is all about.

npm cache

Reference (NPM cache) [docs.npmjs.com/cli/cache]

End~

Welcome to put forward the cause analysis and solution of similar bug. Thank you!

Refenrence:

  1. nvm in github
  2. detail compare
  3. Select the shell with CHSH