NODEJS installation and vue installation and operation methods and the solution to the problem of Cannot find module 'node-sass' Require stack

install nodejs

Official website download:

https://registry.npmmirror.com/binary.html?path=node/

Select the version to download.
It is generally recommended to download the msi
insert image description here
and select your own installation location until the next step to complete.

Check if the installation is successful

Open cmd and enter the following command

node -v
npm -v

insert image description here
If the version number is output, the installation is successful.

insert image description here

Create a global installation directory and a cache log directory

Under our installation directory, create two folders named node_cache and node_global.
insert image description here
Open the Dos window and execute the following command to configure the npm global module directory and cache directory to the two directories we just created.

npm config set prefix "你的安装目录\node_global"

npm config set cache "你的安装目录\node_cache"

insert image description here
In order to download the package quickly in the future, modify the source to Taobao mirror. (It has been modified here, so we don’t need to install cnpm, because cnpm is the Node.js Taobao mirror accelerator, so if it’s configured here, it doesn’t need to be installed)

npm config set registry https://registry.npm.taobao.org

Check whether the npm configuration modification is successful

npm config list

insert image description here
Detailed
insert image description here
insert image description here
explanation Check whether the mirror station works or not

npm config get registry

At the same time, we will find an additional file: the .npmrc file under C:\Users\username\, which can be understood as a configuration file that records the modification information of the current user. If you delete this file, the parameters you just modified will be gone, and you will return to the default configuration.
Modify the content inside (if not added) to the two folders just configured
insert image description here

Edit environment variables

Configure these two in the system environment variable
insert image description here

Configure these contents in the system environment variable path
insert image description here

Configured in the environment variable path
insert image description here

Install VUE

Win + s to search for "Command Prompt", right click and run as administrator.
insert image description here
Run the command to install

npm install vue -g

insert image description here
insert image description here
Check if the installation is successful

vue -V

insert image description here

Install vue-router

Order:

npm install vue-router -g

insert image description here
insert image description here

Install vue scaffolding

npm install vue-cli -g

insert image description here

Enter vue --version, if the version number can be output, it means that it is installed.

Install webpack templates

npm install webpack -g

insert image description here
In addition, above webpack 4x, webpack puts all command-related content into webpack-cli, so webpack-cli needs to be installed

npm install webpack-cli -g

insert image description here
Enter webpack -v, if you can output the version number, it means that it is installed

Run the VUE project

Open cmd and enter the project file.
If there are node_modules and package-lock.json files in the project,
delete the "node_modules" folder and "package-lock.json"
insert image description here

Clear npm cache
When npm has a cache, the installation dependency is often unsuccessful, and once this problem occurs, the error message is complete, but according to the error message to solve one by one, it can't be solved, and the reason can't be found. Enter the following command in the console to clear the npm cache. When npm has a cache, it often fails to install dependencies

npm cache clean -force

Reinstall dependencies

npm install

insert image description here

run project

npm run serve

insert image description here
success:
insert image description here

Install vue and environment and run vue

Solution to the Cannot find module 'node-sass' Require stack problem when running VUE

Syntax Error: Error: Cannot find module 'node-sass' Require stack: - G:\ceshi\ceshi\node_modules\sass-loader\dist\index.js - G:\ceshi\ceshi\node_modules\sass-loader\dist\cjs.js - G:\ceshi\ceshi\node_modules\loader-runner\lib\loadLoader.js - G:\ceshi\ceshi

解决方法:
npm install --save-dev node-sass --registry=https://registry.npm.taobao.org --disturl=https://npm.taobao.org/dist --sass-binary-site=http://npm.taobao.org/mirrors/node-sass

或输入命令 npm install node-sass 或 cnpm install node-sass@latest 直接进行安装即可

Reference documents:

https://blog.csdn.net/m0_57545353/article/details/124366678
https://blog.csdn.net/weixin_44209743/article/details/128899429
https://blog.csdn.net/weixin_43453621/article/details/126585793
https://blog.csdn.net/dream_summer/article/details/108867317
https://ymjin.blog.csdn.net/article/details/121788104

Guess you like

Origin blog.csdn.net/munangs/article/details/130122651