Node is installed several times on the MAC, but often fails when you turn it off and on again. Useful installation package installation, also used Homebrew installation, finally led to management confusion. Today, I found that Node-V is not working well again. Decided to settle it once and for all.

First, try Brew Install Node.

brew install node
Copy the code

Homebrew Warning Node is installed

Error trying brew Link node:

brew link node
Copy the code

Forced the link

brew link --overwrite node
Copy the code

No read/write permission is available for /usr/local/chown command

sudo chown -R $(whoami):admin /usr/local
Copy the code

The command is invalid. Replace it with a new command:

sudo chown -R $(whoami) $(brew --prefix)/*
Copy the code

Brew Linke node error:

Delete, delete all !!!!!

Rm '/ usr/local/include/node/common gypi' brew link - overwrite - dry - run the node (the error ❌ not mandatory link)Copy the code

View node version after deleting a bunch of files :(actually just listing deleted files, not executed link)

Brew Link node still not working…

Force the Link node again

brew link --overwrite node
Copy the code

It works!! 😭 😭 😭

But NPM still doesn’t. 😭 😭 😭

Install the NPM:

brew install npm
Copy the code

Warning ⚠️ :

Try reinstalling Node as prompted:

brew reinstall node
Copy the code

Finally, it worked 🎉🎉🎉

Conclusion:

If homebrew tip installed node, but the brew the link node quote/user/local/node/common gypi file symlink fails, try to delete the corresponding files.

If you do not have the read/write permission and cannot delete files, run the chown command to obtain the read/write permission for the local folder.

sudo chown -R $(whoami):admin /usr/local
Copy the code

Important: Use the following command for a newer MAC OS

sudo chown -R $(whoami) $(brew --prefix)/*
Copy the code

Then use the mandatory link

brew link --overwrite node
Copy the code

Gypi error ❌❌❌ will still be generated if not symlink include/node/common.gypi

After installing node homebrew, NPM may still not work.

brew reinstall node
Copy the code

Then, NPM comes into play. 🍺

From the last step, you may just run Brew Scandisk Node, but there is no test. I will check later and hope that everything will be normal at the next startup. I don’t know if there are any other issues, there are always permissions issues after upgrading the new MAC system, I don’t know if there is a permanent solution.

Supplement:

Executing brew Link –overwrite node forces links and overwrites all conflicting files

Executing brew Link –overwrite –dry-run node simply lists all the files that will be deleted

So the brew link –overwrite –dry-run node I executed earlier just lists the deleted files and really overwrites the installation requires brew Link –overwrite node

What is common. Gypi: www.xuebuyuan.com/2099911.htm…

Therefore, it is possible that the node installation failed due to the interruption of the installation process, and the file is not complete.