问题
由于包里面用到了node-sass,版本为4.9.3,
安装时候发现一直都有报错,类似于这样子的
出现上图报错的原因:
node-sass的版本为4.9.3,而我的node版本为12.22.5,node版本高了
解决:
然后我就将我的node版本降为了10.15.0
出现了新问题
但是由于我们装包需要使用的cnpm,并且需要修改掉它的registry,当我npm install -g cnpm --registry=https://registry.npm.taobao.org
安装了最新的cnpm@8.2.0版本
,并运行 cnpm config set registry=xxx
,发现如下提示
ERROR: npm is known not to run on Node.js v10.15.0
You'll need to upgrade to a newer Node.js version in order to use this
version of npm. You can find the latest version at https://nodejs.org/
出现上面提示的原因:
安装的cnpm版本高了
解决:
期间我又切换到了之前用的node:12.22.5
版本,重新安装了一次cnpm,并且也能修改registry,但是当我cnpm i的时候,出现了“Error:Cannot find module 'fs/promises”
报错,我就参考这个bolg,发现可以通过安装低版本的cnpm来解决问题,于是我又切回到了低版本node
安装低版本cnpm:npm install cnpm@7.1.0 -g --registry=https://registry.npm.taobao.org
这样就可以修改registry了,然后再运行cnpm i
安装依赖就成功了
参考链接
node-sass
cnpm错误:“Error:Cannot find module ‘fs/promises”