由于重新装了一个系统,很多环境配置要重新配置。在想run 一个项目时,出现下面的错误:
error in ./src/page/Index.vueModule build failed: Error: Cannot find module 'node-sass'at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)at Function.Module._load (internal/modules/cjs/loader.js:507:25)at Module.require (internal/modules/cjs/loader.js:637:17)at require (internal/modules/cjs/helpers.js:22:18)at Object.sassLoader (E:\trip_user_ui\node_modules\sass-loader\lib\loader.js:46:72)@ ./node_modules/vue-style-loader!./node_modules/css-loader?{"sourceMap":false}!./node_modules/vue-loader/lib/style-compiler?{"vue":true,"id":"data-v-c221866a","scoped":true,"hasInlineConfig":false}!./node_modules/sass-loader/lib/loader.js?{"sourceMap":false}!./node_modules/vux-loader/src/style-loader.js!./node_modules/vue-loader/lib/selector.js?type=styles&index=0!./src/page/Index.vue 4:14-424 13:3-17:5 14:22-432@ ./src/page/Index.vue@ ./src/router/index.js@ ./src/main.js@ multi (webpack)-dev-server/client?http://0.0.0.0:8080 webpack/hot/dev-server ./src/main.jserror in ./src/page/addPerson.vueModule build failed: Error: Cannot find module 'node-sass'at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)at Function.Module._load (internal/modules/cjs/loader.js:507:25)at Module.require (internal/modules/cjs/loader.js:637:17)at require (internal/modules/cjs/helpers.js:22:18)at Object.sassLoader (E:\trip_user_ui\node_modules\sass-loader\lib\loader.js:46:72)@ ./node_modules/vue-style-loader!./node_modules/css-loader?{"sourceMap":false}!./node_modules/vue-loader/lib/style-compiler?{"vue":true,"id":"data-v-485da622","scoped":true,"hasInlineConfig":false}!./node_modules/sass-loader/lib/loader.js?{"sourceMap":false}!./node_modules/vux-loader/src/style-loader.js!./node_modules/vue-loader/lib/selector.js?type=styles&index=0!./src/page/addPerson.vue 4:14-428 13:3-17:5 14:22-436@ ./src/page/addPerson.vue@ ./src/router/index.js@ ./src/main.js@ multi (webpack)-dev-server/client?http://0.0.0.0:8080 webpack/hot/dev-server ./src/main.jserror in ./src/page/callPolice.vueModule build failed: Error: Cannot find module 'node-sass'at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)at Function.Module._load (internal/modules/cjs/loader.js:507:25)at Module.require (internal/modules/cjs/loader.js:637:17)at require (internal/modules/cjs/helpers.js:22:18)at Object.sassLoader (E:\trip_user_ui\node_modules\sass-loader\lib\loader.js:46:72)@ ./node_modules/vue-style-loader!./node_modules/css-loader?{"sourceMap":false}!./node_modules/vue-loader/lib/style-compiler?{"vue":true,"id":"data-v-31d77fd3","scoped":true,"hasInlineConfig":false}!./node_modules/sass-loader/lib/loader.js?{"sourceMap":false}!./node_modules/vux-loader/src/style-loader.js!./node_modules/vue-loader/lib/selector.js?type=styles&index=0!./src/page/callPolice.vue 4:14-429 13:3-17:5 14:22-437@ ./src/page/callPolice.vue@ ./src/router/index.js@ ./src/main.js@ multi (webpack)-dev-server/client?http://0.0.0.0:8080 webpack/hot/dev-server ./src/main.jserror in ./src/page/passenger.vueModule build failed: Error: Cannot find module 'node-sass'at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)at Function.Module._load (internal/modules/cjs/loader.js:507:25)at Module.require (internal/modules/cjs/loader.js:637:17)at require (internal/modules/cjs/helpers.js:22:18)at Object.sassLoader (E:\trip_user_ui\node_modules\sass-loader\lib\loader.js:46:72)@ ./node_modules/vue-style-loader!./node_modules/css-loader?{"sourceMap":false}!./node_modules/vue-loader/lib/style-compiler?{"vue":true,"id":"data-v-9a9a079a","scoped":true,"hasInlineConfig":false}!./node_modules/sass-loader/lib/loader.js?{"sourceMap":false}!./node_modules/vux-loader/src/style-loader.js!./node_modules/vue-loader/lib/selector.js?type=styles&index=0!./src/page/passenger.vue 4:14-428 13:3-17:5 14:22-436@ ./src/page/passenger.vue@ ./src/router/index.js@ ./src/main.js@ multi (webpack)-dev-server/client?http://0.0.0.0:8080 webpack/hot/dev-server ./src/main.js
然后报错说是找不到node-sass,那么想着install一个node-sass就行了。但是发现结果不是!!!输入命令npm install node-sass --save-dev
报错如下:
gyp info it worked if it ends with okgyp verb cli [ 'C:\\Program Files\\nodejs\\node.exe',gyp verb cli 'E:\\trip_user_ui\\node_modules\\node-gyp\\bin\\node-gyp.js',gyp verb cli 'rebuild',gyp verb cli '--verbose',gyp verb cli '--libsass_ext=',gyp verb cli '--libsass_cflags=',gyp verb cli '--libsass_ldflags=',gyp verb cli '--libsass_library=' ]gyp info using node-gyp@3.8.0gyp info using node@10.15.0 | win32 | x64gyp verb command rebuild []gyp verb command clean []gyp verb clean removing "build" directorygyp verb command configure []gyp verb check python checking for Python executable "python2" in the PATHgyp verb `which` failed Error: not found: python2gyp verb `which` failedat getNotFoundError (E:\trip_user_ui\node_modules\which\which.js:13:12)gyp verb `which` failedat F (E:\trip_user_ui\node_modules\which\which.js:68:19)gyp verb `which` failedat E (E:\trip_user_ui\node_modules\which\which.js:80:29)gyp verb `which` failedat E:\trip_user_ui\node_modules\which\which.js:89:16gyp verb `which` failedat E:\trip_user_ui\node_modules\isexe\index.js:42:5gyp verb `which` failedat E:\trip_user_ui\node_modules\isexe\windows.js:36:5gyp verb `which` failedat FSReqWrap.oncomplete (fs.js:154:21)gyp verb `which` failed python2 { Error: not found: python2gyp verb `which` failedat getNotFoundError (E:\trip_user_ui\node_modules\which\which.js:13:12)gyp verb `which` failedat F (E:\trip_user_ui\node_modules\which\which.js:68:19)gyp verb `which` failedat E (E:\trip_user_ui\node_modules\which\which.js:80:29)gyp verb `which` failedat E:\trip_user_ui\node_modules\which\which.js:89:16gyp verb `which` failedat E:\trip_user_ui\node_modules\isexe\index.js:42:5gyp verb `which` failedat E:\trip_user_ui\node_modules\isexe\windows.js:36:5gyp verb `which` failedat FSReqWrap.oncomplete (fs.js:154:21)gyp verb `which` failed stack:gyp verb `which` failed 'Error: not found: python2\n at getNotFoundError (E:\\trip_user_ui\\node_modules\\which\\which.js:13:12)\n at F (E:\\trip_user_ui\\node_modules\\which\\which.js:68:19)\n at E (E:\\trip_user_ui\\node_modules\\which\\which.js:80:29)\n at E:\\trip_user_ui\\node_modules\\which\\which.js:89:16\n at E:\\trip_user_ui\\node_modules\\isexe\\index.js:42:5\n at E:\\trip_user_ui\\node_modules\\isexe\\windows.js:36:5\n at FSReqWrap.oncomplete (fs.js:154:21)',gyp verb `which` failed code: 'ENOENT' }gyp verb check python checking for Python executable "python" in the PATHgyp verb `which` failed Error: not found: pythongyp verb `which` failedat getNotFoundError (E:\trip_user_ui\node_modules\which\which.js:13:12)gyp verb `which` failedat F (E:\trip_user_ui\node_modules\which\which.js:68:19)gyp verb `which` failedat E (E:\trip_user_ui\node_modules\which\which.js:80:29)gyp verb `which` failedat E:\trip_user_ui\node_modules\which\which.js:89:16gyp verb `which` failedat E:\trip_user_ui\node_modules\isexe\index.js:42:5gyp verb `which` failedat E:\trip_user_ui\node_modules\isexe\windows.js:36:5gyp verb `which` failedat FSReqWrap.oncomplete (fs.js:154:21)gyp verb `which` failed python { Error: not found: pythongyp verb `which` failedat getNotFoundError (E:\trip_user_ui\node_modules\which\which.js:13:12)gyp verb `which` failedat F (E:\trip_user_ui\node_modules\which\which.js:68:19)gyp verb `which` failedat E (E:\trip_user_ui\node_modules\which\which.js:80:29)gyp verb `which` failedat E:\trip_user_ui\node_modules\which\which.js:89:16gyp verb `which` failedat E:\trip_user_ui\node_modules\isexe\index.js:42:5gyp verb `which` failedat E:\trip_user_ui\node_modules\isexe\windows.js:36:5gyp verb `which` failedat FSReqWrap.oncomplete (fs.js:154:21)gyp verb `which` failed stack:gyp verb `which` failed 'Error: not found: python\n at getNotFoundError (E:\\trip_user_ui\\node_modules\\which\\which.js:13:12)\n at F (E:\\trip_user_ui\\node_modules\\which\\which.js:68:19)\n at E (E:\\trip_user_ui\\node_modules\\which\\which.js:80:29)\n at E:\\trip_user_ui\\node_modules\\which\\which.js:89:16\n at E:\\trip_user_ui\\node_modules\\isexe\\index.js:42:5\n at E:\\trip_user_ui\\node_modules\\isexe\\windows.js:36:5\n at FSReqWrap.oncomplete (fs.js:154:21)',gyp verb `which` failed code: 'ENOENT' }gyp verb could not find "python". checking python launchergyp verb could not find "python". guessing locationgyp verb ensuring that file exists: C:\Python27\python.exegyp ERR! configure errorgyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.gyp ERR! stackat PythonFinder.failNoPython (E:\trip_user_ui\node_modules\node-gyp\lib\configure.js:484:19)gyp ERR! stackat PythonFinder.<anonymous> (E:\trip_user_ui\node_modules\node-gyp\lib\configure.js:509:16)gyp ERR! stackat E:\trip_user_ui\node_modules\graceful-fs\polyfills.js:282:31gyp ERR! stackat FSReqWrap.oncomplete (fs.js:154:21)gyp ERR! System Windows_NT 10.0.16299gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "E:\\trip_user_ui\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="gyp ERR! cwd E:\trip_user_ui\node_modules\node-sassgyp ERR! node -v v10.15.0gyp ERR! node-gyp -v v3.8.0gyp ERR! not okBuild failed with error code: 1npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules\fsevents):npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})npm ERR! code ELIFECYCLEnpm ERR! errno 1npm ERR! node-sass@4.10.0 postinstall: `node scripts/build.js`npm ERR! Exit status 1npm ERR!npm ERR! Failed at the node-sass@4.10.0 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\zsm\AppData\Roaming\npm-cache\_logs\-01-14T11_48_54_017Z-debug.log
先前npm install 也是报这种类似的错误。
后来搜索出cnpm install node-sass --save
这个命令可能有用,但是要事先安装cnpm。所以npm i cnpm时又是一通报错。
所以用npm install -g cnpm --registry=https://registry. ,从淘宝镜像那下载,然后cnpm下载成功。
最后输入cnpm install node-sass --save。npm run dev终于能跑起来了!!!