What should I do if node.js npm cannot be used?
Node.js npm cannot be used Solution: 1. Uninstall node.js; 2. Delete npm and npm-cache under "C:\Users\Administrator\AppData\Roaming"; 3. Reinstall Node.js is enough.
The operating environment of this article: Windows 7 system, nodejs version 8.9.3, Dell G3 computer.
What should I do if node.js npm cannot be used?
About the solution to the inability to use npm after nodejs is installed:
Because it is required to use vue in conjunction with node for project development environment deployment, try to install nodejs.
As for what others said after installing version 6, it will be stable. In fact, after installing version 6, you can use global npm.
Node.js installation package and source code download address is: https ://nodejs.org/en/download/.
##Select this Enter all the way
##Click to agree and it will be installed to the C drive by default
After installation, click the [Finish] button to complete the installation
At this point, Node.js has been installed. You can perform a simple test first to see if the installation is successful. There will be more details later. To configure the environment
Press the [win R] key on the keyboard, enter cmd, and then press Enter to open the cmd windowThis window does not have administrator rights at this time
This is an important point!!!!
## This is the normal installation effect if the C drive has not been touched before
ERR error This means the path is wrong The npm package under that folder cannot be found.
Press [win R] on the keyboard Key, enter cmd, then press Enter to open the cmd window
node -v is normal, npm -v reports an error
As shown below:
Error: Cannot find module 'internal/fs'…
The solution is as follows:
1. Uninstall node.js, specific operations:
2. Delete npm under C:\Users\Administrator\AppData\Roaming , The specific operation of npm-cache is as follows:
3. Reinstall node.js, and enter node -v and npm -v in dos again. You can see the corresponding version number as shown in the text. Shown in a picture.
Follow the steps to install once. The command to open this time must be window x
Select the command prompt (Administrator A) and click to operate
Then check node -v to view the version npm -v to view the version It will return to normal
After installation, click the [Finish] button to complete the installation
At this point, Node.js has been installed. You can first simply test whether the installation is successful, and then configure the environment.
Press the [win R] key on the keyboard, enter cmd, and then press Enter. Open the cmd window
Here is a description: The new version of Node.js has its own npm, which will be installed together when installing Node.js. The role of npm is to manage the packages that Node.js depends on, which is also understandable. What you need to install/uninstall Node.js
5. Environment Configuration
Description: The environment configuration here mainly configures the path where the global module installed by npm is located, and the path of the cache. The reason for configuring it is because it will be executed similarly in the future: When using the installation statement of npm install express [-g] (the following optional parameter -g, g represents global installation), the installed module will be installed to [C:\Users\username\AppData\Roaming\npm 】path, occupying C drive space.
For example: I want to put the path of the full module and the cache path in the folder where I installed node.js, then create two folders [node_global] under the folder I installed [D:\Develop\nodejs] ] and [node_cache] as shown below:
After creating two empty folders, open the cmd command window, enter
npm config set prefix "D:\Develop\nodejs\node_global" npm config set cache "D:\Develop\nodejs\node_cache"
, then set the environment variables, close the cmd window, "My Computer "-Right click-"Properties"-"Advanced System Settings"-"Advanced"-"Environment Variables"
Enter the environment variables dialog box, create a new [NODE_PATH] under [System Variables], enter [D:\ Develop\nodejs\node_global\node_modules], change [Path] under [User Variables] to [D:\Develop\nodejs\node_global]
6. Test
After configuration, After installing a module for testing, we will install the most commonly used express module, open the cmd window,
Enter the following command to install the module globally:
npm install express -g # -g是全局安装的意思
Add Taobao image
After installation, click the [Finish] button to complete the installation.
At this point, Node.js has been installed. You can first perform a simple test to see if the installation is successful, and then configure the environment.
On the keyboard Press the [win R] key, enter cmd, then press Enter to open the cmd window
How to use mirroring (any of the three methods can solve the problem, it is recommended to use the third method, hard-code the configuration, The configuration will still be there when you use it next time):
1. Pass the config command
npm config set registry https://registry.npm.taobao.org npm info underscore (如果上面配置正确这个命令会有字符串response)
2. Specify
npm --registry https://registry.npm.taobao.org info underscore
3 on the command line. Edit ~/.npmrc
Add the following content
registry = https://registry.npm.taobao.org
安装完后点击【Finish】按钮完成安装
至此Node.js已经安装完成,可以先进行下简单的测试安装是否成功了,后面还要进行环境配置
在键盘按下【win+R】键,输入cmd,然后回车,打开cmd窗口
推荐学习:《node.js视频教程》
The above is the detailed content of What should I do if node.js npm cannot be used?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

This article will give you an in-depth understanding of the memory and garbage collector (GC) of the NodeJS V8 engine. I hope it will be helpful to you!

The Node service built based on non-blocking and event-driven has the advantage of low memory consumption and is very suitable for handling massive network requests. Under the premise of massive requests, issues related to "memory control" need to be considered. 1. V8’s garbage collection mechanism and memory limitations Js is controlled by the garbage collection machine

Choosing a Docker image for Node may seem like a trivial matter, but the size and potential vulnerabilities of the image can have a significant impact on your CI/CD process and security. So how do we choose the best Node.js Docker image?

Node 19 has been officially released. This article will give you a detailed explanation of the 6 major features of Node.js 19. I hope it will be helpful to you!

The file module is an encapsulation of underlying file operations, such as file reading/writing/opening/closing/delete adding, etc. The biggest feature of the file module is that all methods provide two versions of **synchronous** and **asynchronous**, with Methods with the sync suffix are all synchronization methods, and those without are all heterogeneous methods.

The event loop is a fundamental part of Node.js and enables asynchronous programming by ensuring that the main thread is not blocked. Understanding the event loop is crucial to building efficient applications. The following article will give you an in-depth understanding of the event loop in Node. I hope it will be helpful to you!

How to package nodejs executable file with pkg? The following article will introduce to you how to use pkg to package a Node project into an executable file. I hope it will be helpful to you!

How does Node.js do GC (garbage collection)? The following article will take you through it.
