因为因为网络原因导致的node-modules的部分文件缺失,在npm install 时报错如下:
但此时有node-modules,启动项目会报:Error: Cannot find module 'node-sass'
解决方法如下:
1. npm install -g cnpm --registry=https://registry.npm.taobao.org
2. cnpm install node-sass@版本
3. 启动项目
注意事项: 如果直接安装了cnpm install node-sass 启动项目是报如下:
Node Sass version 5.0.0 is incompatible with ^4.0.0.
是因为node-sass的版本不对,需要将其降级为4.0的版本
解决方法:
1. npm uninstall node-sass (卸载原来的sass)
2. npm install node-sass@版本 (安装对应的版本: 例如:cnpm install node-sass@4.14.1)