Windows under node config NPM global path (stepping pit)

Source: Internet
Author: User

The cause of the matter is: KOA requires v7.6.0 above the Nodejs.

However, the window environment to upgrade node is not easy, tried NPM install-g N and N stable and other commands are not valid, and the online recommended NVM does not support windows, and NVM for Windows requires first delete node and related configuration, And this is not perfect for Windows-enabled NVM. In the risk-averse consideration, we decided to remove and reload Nodejs.

The problem is, in a netizen's tutorial, mentions modifying the global path of NPM installation:

NPM config set prefix "D:\Develop\nodejs\node_global""D:\Develop\nodejs\node_cache"

Right-click My Computer, properties, advanced system settings, advanced/environment variables, new Node_path in system variables, input D:\Develop\nodejs\node_global\node_modules,

Change path to D:\Develop\nodejs\node_global in user variables

But after I tried it, I found that NPM had been reporting an error, saying access to Nodejs's Node_global, which was installed on the C-drive; After several unsuccessful attempts, the path was modified back to AppData, but the same error was reported.

Uninstall Nodejs several times, delete npm related folders or this.

Solution :

Finally, it is found that the NPM operation must be performed with CMD with administrator privileges, because the program files in the C drive, with Git bash, do not have permission to write the file and therefore fail.

My Nodejs is installed by default in the C drive program files, listen to the Netizen suggested to set the global path under the Nodejs installation path, and just program files need permission to read and write operations.

The correct way to do this is to set the global path to a place where administrator privileges are not required.

So I re-installed the Nodejs again and set the global path to the installation directory with the CMD of administrator rights. Problem solved.

Windows under node config NPM global path (stepping pit)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.