node 14 对sass和sass-loader的依赖和node 16是不同的。当一个项目,由node14开发,但是本地环境又是node 16, 该怎么解决呢?
这里可以用到node16的自动安装,直接执行:
npm install sass
npm install sass-loader
安装完成后,通过下面命令查看已安装的脚本
# 以树型结构列出当前项目安装的所有模块,以及它们依赖的模块。
npm list
# 列出全局安装的模块。
npm list -global
然后把查询到的版本写入到package.json中即可。
npm run build:prod
构建出来的是生产环境的应用,生成的包会比较小
npm run build:stage
构建出来的是测试环境的应用
NVM包管理
在nvm包管理目录下,解压下载的node,下载地址:node
npm或yarm指定淘宝镜像
# npm命令
npm config get registry
# yarn命令
yarn config get registry
修改为淘宝镜像
# npm命令
npm config set registry http://registry.npm.taobao.org/
# yarn命令
yarn config set registry http://registry.npm.taobao.org/
安装windows平台编译环境(需要在管理员权限下安装)
npm install -g node-gyp npm install --global --production windows-build-tools
当然也可在项目目录下临时安装指定node-sass为镜像淘宝
npm i node-sass --sass_binary_site=https://npm.taobao.org/mirrors/node-sass/
安装yarm
sudo npm i -g yarn yarn 或者 yarn install //安装所有的依赖包 yarn add [package]@[version] //添加一个依赖包 yarn remove package //移除某个依赖项目
TypeError: Cannot read property 'range' of null错误解决方法
一般原因:babel-eslint版本太高了。比如:"babel-eslint": "^10.0.3"
解决方法:删除node_modules/babel-eslint
npm i babel-eslint@7.2.3