First, the versions of nodejs and npm are adapted.
First look at the approximate matches listed on the official website:
Official website link address:/zh-cn/about/previous-releases
You can check your local version to see if the difference is too large according to the table above. If the difference is too big, you need to update to the corresponding version, otherwise you will get all kinds of errors, which will cause npm commands to fail.
Example of the current version of the blogger:
>npm -v
6.14.18
>node -v
v14.18.0
// "node-sass": "^4.14.1"
// "sass-loader": "^7.3.0"
II. Version updates
2.1 The nvm utility is recommended for switching between versions directly from the command line.
The nvm utility is recommended for both Windows and Linux platforms.
nvm( Version Management)The nodejs versioning tool is a versioning tool for nodejs. It is designed to solve the problem of incompatibility between various versions.It allows you to install and switch between different versions of , as well as install multiple versions (and the accompanying npm) in a single environment at the same time., which makes it much easier in day-to-day development.
However, it is important to note that before installing nvm, you need to remove all the nodejs you have installed.
Details are available:/goods_yao/article/details/137854626
2.2 Manual updates
Of course, in addition to updating through the toolIt can also be installed manuallyThe following is a recommended Aliyun address for downloading nodejs, which contains a history of the various versions.
Installation package download address:/nodejs-release/
Click on the corresponding version to go to the details and there will be installation files for each platform.
- Windows platform
You can download the .msi installer for your system. Nowadays there are not many 32-bit systems left, so you can usually download the x64 version.
Just double-click and install it directly after downloading.
Detailed installation steps for nodejs can be found here:/Nicolecocol/article/details/136788200
npm is a package manager for distributing and managing application dependencies.
Normally, npm is automatically included in the installation and does not need to be downloaded and configured separately.
if it is to beUpdate the specified version of npm, you can refer to the following command:
npm install -g npm
npm install -g npm@<Specify version number>
npm install -g [email protected]
- Linux platform
Installation steps can be referred to:/qq_40743057/article/details/139139574
Note that CentOS 7 supports up to version . Installing a higher version of , such as , on CentOS 7 may result in compatibility issues and error reporting on your system. This is because as versions are updated, their dependent libraries and modules may change, which may conflict with older packages on CentOS 7. To ensure proper operation and avoid potential errors, it is recommended that you install the officially recommended version on CentOS 7. This version has been fully tested and verified for compatibility with CentOS 7 and provides a stable environment.
III. Several error messages encountered
3.1 Node Sass could not find a binding for your current environment...
Error Reporting Content:
// execute a command npm run dev "Times" error:
Node Sass could not find a binding for your current environment: Windows 64-bit with
// fulfillment npm The command reports an error.:
Failed to resolve loader: sass-loader You may need to install it. Error from chokidar (E:\): Error: EBUSY: resource busy or locked
The reason for the error is that the project may be differentiating between test and formal service configurations.
You can try to fix it with the following command:
// The default is to operate in the official service
// Uninstall first, then install
npm uninstall sass-loader node-sass
npm install sass-loader node-sass
// If you need to update the test environment again, you need to add the following configuration: --save-dev
npm uninstall sass-loader node-sass --save-dev
npm install sass-loader node-sass --save-dev
// Install the specified version
npm uninstall node-sass
npm install [email protected]
npm install node-sass@latest
3.2 errno: -4071, code: 'EINVAL', syscall: 'spawnSync ', path: '' ...
Report Error Details:
Initialization Error
errno: -4071, code: 'EINVAL', syscall: 'spawnSync ', path: '',
arco design Error initializing project: x Failed to copy template content Error: spawnSync EINVAL
The reason is that child_process.spawn has a vulnerability (CVE-2024-27980)-(HIGH), which is called with { shell: true }. 2024.4.10 node fixed this vulnerability, and the code executes incorrectly. cli downloads arco-design-pro-vue and executes it to . cli\ and it spawns.
Workaround: Just use versions prior to 18.20.2, 20.12.2, 21.17.3. I'm fine with version 18.20.0.
Solution Reference:/arco-design/arco-cli/issues/92
3.3 Taobao Mirror Address Certificate Expired
Report Error Details:
request to /axios failed, reason: certificate has expired
Solution:
Backing up your npm configuration first prevents you from losing it during the changeover process
npm config get > npm_config.txt
npm config set registry
npm install --save-dev @arco-design/web-vue
npm i -g arco-cli
3.4 Error: Command 「yarn 」 executed failed
Report Error Details:
× Project Dependency An Failure,You can try installing the project dependencies manually later
Error: Command 「yarn 」 executed failed:
warning ..\: No license field
warning gifsicle > bin-build > tempfile > [email protected]: Please upgrade to version 7 or higher.
。。。
Solution:
Open the command line and switch to the project directory, e.g.: cd your_project_directory
Run the following command to clear the previous dependency cache: yarn cache clean
Update the project's dependency packages: yarn upgrade
Reinstall project dependencies: yarn install
3.5 Error when executing npm command: Error: Cannot find module 'node:path'
The possible reason is that the versions of nodejs and npm don't match. Upgrade nodejs according to the version relationship in the first section of this article.