Table of Contents
node -v is normal, npm -v reports an error
As shown below:
The solution is as follows:
5. Environment Configuration
6. Test
Home Web Front-end JS Tutorial What should I do if node.js npm cannot be used?

What should I do if node.js npm cannot be used?

Dec 10, 2021 am 11:11 AM
node.js

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.

What should I do if node.js npm cannot be used?

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 window

This 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

Otherwise this will happen

ERR error This means the path is wrong The npm package under that folder cannot be found.

At this time, check if you have used npm before. If so, delete and reinstall

Delete cleanly

After installation Click the [Finish] button to complete the installation

Now Node.js has been installed. You can first briefly test whether the installation is successful, and then configure the environment.

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:

What should I do if node.js npm cannot be used?
Error: Cannot find module 'internal/fs'…

The solution is as follows:

1. Uninstall node.js, specific operations:
What should I do if node.js npm cannot be used?

2. Delete npm under C:\Users\Administrator\AppData\Roaming , The specific operation of npm-cache is as follows:
What should I do if node.js npm cannot be used?

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"
Copy after login

, 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是全局安装的意思
Copy after login

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)
Copy after login

2. Specify

npm --registry https://registry.npm.taobao.org info underscore
Copy after login

3 on the command line. Edit ~/.npmrc Add the following content

registry = https://registry.npm.taobao.org
Copy after login

安装完后点击【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!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Detailed graphic explanation of the memory and GC of the Node V8 engine Detailed graphic explanation of the memory and GC of the Node V8 engine Mar 29, 2023 pm 06:02 PM

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!

An article about memory control in Node An article about memory control in Node Apr 26, 2023 pm 05:37 PM

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

Let's talk about how to choose the best Node.js Docker image? Let's talk about how to choose the best Node.js Docker image? Dec 13, 2022 pm 08:00 PM

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.js 19 is officially released, let's talk about its 6 major features! Node.js 19 is officially released, let's talk about its 6 major features! Nov 16, 2022 pm 08:34 PM

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!

Let's talk in depth about the File module in Node Let's talk in depth about the File module in Node Apr 24, 2023 pm 05:49 PM

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.

Let's talk about the event loop in Node Let's talk about the event loop in Node Apr 11, 2023 pm 07:08 PM

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!

Let's talk about how to use pkg to package Node.js projects into executable files. Let's talk about how to use pkg to package Node.js projects into executable files. Dec 02, 2022 pm 09:06 PM

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!

Let's talk about the GC (garbage collection) mechanism in Node.js Let's talk about the GC (garbage collection) mechanism in Node.js Nov 29, 2022 pm 08:44 PM

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

See all articles