Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The solution that npm can't be used in node.js

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This post is about the workarounds in node.js that npm doesn't use. Xiaobian thinks it is quite practical, so share it with everyone for reference. Let's follow Xiaobian and have a look.

Node.js npm does not use the solution: 1, uninstall node.js;2, delete "C:\Users\Administrator\AppData\Roaming" under the npm and npm-cache;3, reinstall node.js.

Operating environment: Windows 7 system, nodejs version 8.9.3, Dell G3 computer.

About nodejs after installation can not use npm solution:

Since you require vue and node for project development environment deployment, try installing nodejs.

As for what others say about installing version 6, it will be stable. In fact, after installing version 6, it can be global npm .

Node.js installation package and source code download address: https://nodejs.org/en/download/.

Choose this one all the way to Enter

Click Agree to install to drive C by default

After installation, click the [Finish] button to complete installation.

At this point Node.js has been installed, you can first carry out a simple test whether the installation is successful, and then you have to configure the environment

Press the [win+R] key on the keyboard, enter cmd, and then enter to open the cmd window. At this time, this window does not have administrator privileges.

Focus here!!!

This is the normal installation effect if there is no C disk before the move things

Otherwise, this will happen.

ERR Error This is the wrong path and cannot find the npm package under that folder.

Check if you have used NPM before and if you have reinstalled it.

Delete clean

After installation, click the [Finish] button to complete installation.

At this point Node.js has been installed, you can first carry out a simple test whether the installation is successful, and then you have to configure the environment

Press the [win+R] key on the keyboard, type cmd, and then enter to open the cmd window.

node -v normal, npm -v error as shown in the figure below:

Error: Cannot find module 'internal/fs'…

The solution is as follows:

1. Uninstall node.js, specific operation:

2. Delete npm and npm-cache under C:\Users\Administrator\AppData\Roaming. The specific operations are as follows:

3. Reinstall node.js, and enter node-v and npm-v in dos again to see the corresponding version number as shown in the first picture of the text.

Follow the steps to install once. The command to open this time must be window + x.

Select Command Prompt (Administrator A) Click to proceed

Then check node -v to see the version npm -v to see the version will return to normal

After installation, click the [Finish] button to complete installation.

At this point Node.js has been installed, you can first carry out a simple test whether the installation is successful, and then you have to configure the environment

Press the [win+R] key on the keyboard, type cmd, and then enter to open the cmd window.

Note here: The new version of Node.js has its own npm, which will be installed when installing Node.js. The role of npm is to manage the packages that Node.js depends on. It can also be understood as the things that need to be installed to install/uninstall Node.js.

V. Environmental configuration

Description: The environment configuration here mainly configures the path where the global module installed by npm is located and the path of cache. The reason why it needs to be configured is that when the installation statement similar to: npm install express [-g](optional parameter-g later, g stands for global global installation) is executed, the installed module will be installed in the path [C:\Users\username\AppData\Roaming\npm], occupying the space of C disk.

For example, if I want to place the path of all modules and cache path in the folder installed by my node.js, then create two folders [node_global] and [node_cache] under the folder [D:\Develop\nodejs] installed by me, as shown below:

After creating the two empty folders, open the cmd command window and type

npm config set prefix "D:\Develop\nodejs\node_global"npm config set cache "D:\Develop\nodejs\node_cache"

Next set environment variables, close 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], and modify [Path] under [User Variables] to [D:\Develop\nodejs\node_global].

VI. Testing

After configuration, install a module test, we 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 means global installation Add Taobao mirror

After installation, click the [Finish] button to complete installation.

At this point Node.js has been installed, you can first carry out a simple test whether the installation is successful, and then you have to configure the environment

Press the [win+R] key on the keyboard, type cmd, and then enter to open the cmd window.

Mirror usage method (any of the three methods can solve the problem, it is recommended to use the third method, the configuration is written dead, the configuration is still in the next time):

1. Via config command

npm config set registry https://registry.npm.taobao.org npm info underscore (if configured correctly this command will have the string response)

2. specified on the command line

npm --registry https://registry.npm.taobao.org info underscore

3. Edit ~/.npmrc Add the following

registry = https://registry.npm.taobao.org

After installation, click the [Finish] button to complete installation.

At this point Node.js has been installed, you can first carry out a simple test whether the installation is successful, and then you have to configure the environment

Press the [win+R] key on the keyboard, type cmd, and then enter to open the cmd window.

Thank you for reading! About "node.js npm can not use the solution" This article is shared here, I hope the above content can be of some help to everyone, so that everyone can learn more knowledge, if you think the article is good, you can share it to let more people see it!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report