解决`gyp` failed with exit code: 1的问题(启动项目报错:Error: Cannot find module 'node-sass')


因为因为网络原因导致的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)

  




 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM