1.使用npm run dev 启动项目时,报错:
ERROR Failed to compile with 19 errors 9:48:05 ├F10: AM┤
error in ./src/styles/index.scss
Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
Error: Cannot find module 'node-sass'
2.发现需要安装,node-sass,然后npm install node-sass,结果又报错:
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-sass@4.14.1 postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-sass@4.14.1 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Administrator\AppData\Roaming\npm-cache\_logs\2020-08-27T02_01_22_004Z-debug.log
这是因为sass安装时获取源的问题,修改sass安装的源,使用淘宝的npm,如下:
npm config set sass_binary_site=https://npm.taobao.org/mirrors/node-sass
然后再运行:
npm install
项目正常启动。