一、下载Nodejs(可下载不同版本)
或者所有历史版本请访问:Index of /dist/https://nodejs.org/dist/
选择对应的版本,window下载msi文件,安装时一直NEXT就行
下面链接为自用安装包:https://download.youkuaiyun.com/download/joyloveit/89729223
检测安装是否成功
二、修改npm镜像
一般国内用户还是建议使用淘宝镜像,所以推荐还是设置成用淘宝镜像,执行:
npm config set registry https://registry.npmmirror.com
三、
查看当前的npm镜像设置:npm config list
构建项目常用指令
# install dependencies
npm install
# serve with hot reload at localhost:8080
npm run dev
# build for production with minification
npm run build
# build for production and view the bundle analyzer report
npm run build --report
#清空缓存
npm cache clean --force
四、安装cnpm
#需要现在对应的目录里创建文件夹,然后再config
npm config set prefix "D:\Program Files\nodejs\node_global"
npm config set cache "D:\Program Files\nodejs\node_cache"
#默认cnpm可能不匹配报错,需要指定版本加@8.5.1
npm install -g cnpm@8.5.1
检测:
需要添加环境变量:D:\Program Files\nodejs\node_global
五、项目启动时报错
1、报python路径找不到,安装对应的python版本,并设置好环境变量
gyp verb check python checking for Python executable "python2" in the PATH
gyp verb `which` failed Error: not found: python2
二、npm install仍旧报错,
Node Sass does not yet support your current environment: Windows 64-bit with Unsupported runtime (64)
分析原因:node-sass库有问题:Node-sass是一个库,它将Node.js绑定到LibSass(流行样式表预处理器Sass的C版本)。它允许用户以令人难以置信的速度将.scss文件本地编译为css,并通过连接中间件自动编译
此问题是npm和node-saas版本不匹配造成的
修改node-sass库版本,保证版本匹配,
#卸载
npm uninstall --save node-sass
#安装
npm install --save node-sass@4.14.1
或者配置淘宝镜像源后使用以下指令
cnpm uninstall node-sass --save-dev
cnpm install node-sass --save-dev
修改项目中node-sass版本
根目录下执行npm install,执行成功。