1. The difference between npm and cnpm:
(1) The difference between the two is only the package manager in node,
(2) npm is the official package manager of node. cnpm is a Chinese version of npm, a cnpm (gzip compression support) command-line tool customized by Taobao to replace the default npm: (3) If you cannot use npm to
download due to network reasons, then cnpm will come in handy.
npm and cnpm are just different downloaders. It seems that npm uses a manpower cart to pull packages, while cnpm uses a truck to deliver packages. The address of the package can be checked in nrm.
2. The use of nrm:
The npm source manager allows you to quickly switch between npm sources.
3. Node installation:
Normal installation: https://nodejs.org/dist/
Check the situation: node -v
and npm -v
Check the node installation path:which node
/usr/local/bin/node
Open the configuration file, configure PATH
input: vi ./.bash_profile
add a line of PATH (press i to enter insert to edit)
export NODE_HOME="/usr/local"
export PATH=$PATH:$NODE_HOME/bin
Press esc to exit insert, enter: wq, press Enter, save the file, the configuration is successful, check whether the configuration is successful Note
⚠️: The path of NODE_HOME is the directory where node is installed
eg: 我的node安装在根目录下的node文件下其路径就是/usr/local
, the node installation path (the parent path of the bin path)
Re-open the terminal, enter node, you will enter the node environment,
control+c
press twice to exit the node environment
The following problem occurs: I am here: there is no lib folder under '/Users/nodejs/node_global/lib', it will be fine after creation
npm ERR! code ENOENT
npm ERR! syscall lstat
npm ERR! path /Users/nodejs/node_global/lib
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, lstat '/Users/nodejs/node_global/lib'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/nodejs/node_cache/_logs/2023-04-16T19_23_18_744Z-debug.log
vue -V checks the version of vue-cli and verifies whether it has been installed, and finds that it is not found
Check the message:
added 230 packages, and audited 230 packages in 17s
11 packages are looking for funding
run `npm fund` for details
6 vulnerabilities (3 moderate, 3 high)
Some issues need review, and may require choosing
a different dependency.
Run `npm audit` for details.
Use npm audit to report an error, and then continue to use npm audit fix --force, it still doesn't work.
Re-modified: Clean up npm cache data
npm cache clean --force
Clear buffer
Finally found out: the version of node.js is wrong, and I found it from the message.
Uninstall from the beginning, method: https://mp.csdn.net/mp_blog/creation/success/130191502
After continuing to check that there is no error, install cnpm
npm install -g cnpm --registry=https://registry.npm.taobao.org
Install with the highest authority, I don’t know if it works:
sudo npm install -g cnpm --registry=https://registry.npm.taobao.org --verbose
Display this error: npm WARN deprecated @npmcli/[email protected]: This functionality has been moved to @npmcli/fs
If you encounter this situation during installation, it means that the npm version needs to be updated
npm install -g npm
Still wrong, the query says that the mirror has been changed: https://developer.aliyun.com/mirror/NPM
http://npm.taobao.org => http://npmmirror.com
http://registry.npm.taobao.org => http://registry.npmmirror.com
In the end, it was still not good, so I moved to another article to deal with it:
Summary: Install node.js to set up the environment, install webpack, install vue-cli and set project information, and finally