1. ホーム
  2. git

モジュールのビルドに失敗しました。Error: Cannot find module 'node-sass' (モジュール 'node-sass')。

2022-02-13 07:04:16

システムを再インストールした結果、多くの環境設定を再設定する必要があります。プロジェクトを実行しようとすると、次のエラーが発生します。

 error in . /src/page/Index.vue

Module 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/vu
e-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.js

 error in . /src/page/addPerson.vue

Module 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/vu
e-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.js

 error in . /src/page/callPolice.vue

Module 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/vu
e-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.js

 error in . /src/page/passenger.vue

Module 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/vu
e-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が見つからないと報告されたので、node-sassをインストールすればいいのかと思ったのです。しかし、結果は違う! npm install node-sass --save-dev というコマンドを入力します。

以下のようにエラーが報告されます。

gyp info it worked if it ends with ok
gyp 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_ext=', gyp verb cli '--libsass_cflags=',
gyp verb cli '--libsass_ldflags=', gyp verb cli '--libsass_ldflags=',
gyp verb cli '--libsass_library=' ]
gyp info using [email protected]
gyp info using [email protected] | win32 | x64
gyp verb command rebuild []
gyp verb command clean []
gyp verb clean removing "build" directory
gyp verb command configure []
gyp verb check python checking for Python executable "python2" in the PATH
gyp verb `which` failed Error: not found: python2
gyp verb `which` failed at getNotFoundError (E:\trip_user_ui\node_modules\which\which.js:13:12)
gyp verb `which` failed at F (E:\trip_user_ui\node_modules\which\which.js:68:19)
gyp verb `which` failed at E (E:\trip_user_ui\node_modules\which\which.js:80:29)
gyp verb `which` failed at E:\trip_user_ui\node_modules\which\which.js:89:16
gyp verb `which` failed at E:\trip_user_ui\node_modules\isexe\index.js:42:5
gyp verb `which` failed at E:\trip_user_ui\node_modules\isexe\windows.js:36:5
gyp verb `which` failed at FSReqWrap.oncomplete (fs.js:154:21)
gyp verb `which` failed python2 { Error: not found: python2
gyp verb `which` failed at getNotFoundError (E:\trip_user_ui\node_modules\which\which.js:13:12)
gyp verb `which` failed at F (E:\trip_user_ui\node_modules\which\which.js:68:19)
gyp verb `which` failed at E (E:\trip_user_ui\node_modules\which\which.js:80:29)
gyp verb `which` failed at E:\trip_user_ui\node_modules\which\which.js:89:16
gyp verb `which` failed at E:\trip_user_ui\node_modules\isexe\index.js:42:5
gyp verb `which` failed at E:\trip_user_ui\node_modules\isexe\windows.js:36:5
gyp verb `which` failed at 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:8
9: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 PATH
gyp verb `which` failed Error: not found: python
gyp verb `which` failed at getNotFoundError (E:\trip_user_ui\node_modules\which\which.js:13:12)
gyp verb `which` failed at F (E:\trip_user_ui\node_modules\which\which.js:68:19)
gyp verb `which` failed at E (E:\trip_user_ui\node_modules\which\which.js:80:29)
gyp verb `which` failed at E:\trip_user_ui\node_modules\which\which.js:89:16
gyp verb `which` failed at E:\trip_user_ui\node_modules\isexe\index.js:42:5
gyp verb `which` failed at E:\trip_user_ui\node_modules\isexe\windows.js:36:5
gyp verb `which` failed at FSReqWrap.oncomplete (fs.js:154:21)
gyp verb `which` failed python { Error: not found: python
gyp verb `which` failed at getNotFoundError (E:\trip_user_ui\node_modules\which\which.js:13:12)
gyp verb `which` failed at F (E:\trip_user_ui\node_modules\which\which.js:68:19)
gyp verb `which` failed at E (E:\trip_user_ui\node_modules\which\which.js:80:29)
gyp verb `which` failed at E:\trip_user_ui\node_modules\which\which.js:89:16
gyp verb `which` failed at E:\trip_user_ui\node_modules\isexe\index.js:42:5
gyp verb `which` failed at E:\trip_user_ui\node_modules\isexe\windows.js:36:5
gyp verb `which` failed at 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.j
s:154:21)',
gyp verb `which` failed code: 'ENOENT' }
gyp verb could not find "python". checking python launcher
gyp verb could not find "python". guessing location
gyp verb ensuring that file exists: C:\Python27\python.exe
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
gyp ERR! stack at PythonFinder.failNoPython (E:\trip_user_ui\node_modules\node-gyp\lib\configure.js:484:19)
gyp ERR! stack at PythonFinder.<anonymous> (E:\trip_user_ui\node_modules\node-gyp\lib\configure.js:509:16)
gyp ERR! stack at E:\trip_user_ui\node_modules\graceful-fs\polyfills.js:282:31
gyp ERR! stack at FSReqWrap.oncomplete (fs.js:154:21)
gyp ERR! System Windows_NT 10.0.16299
gyp ERR! command "C:\\Program Files\\\nodejs\\\node.exe" "E:\\\trip_user_ui\\\\node_modules\\\\node-gyp\\\bin\\\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libs
ass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd E:\trip_user_ui\node_modules\node-sass
gyp ERR! node-v v10.15.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
Build failed with error code: 1
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch& quot;:"any"} (current: {"os":"win32","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall: `node scripts/build.js`
Exit status 1
npm ERR!
Failed at the [email protected] postinstall script. npm ERR!
This is probably not a problem with npm. There is likely additional logging output above.

A complete log of this run can be found in:
C:\Users\zsm\Ap

以前はnpm installで同様のエラーが報告されていました。

その後、cnpm install node-sass --save で検索してみました。
このコマンドはうまくいきそうですが、あらかじめcnpmをインストールしておく必要があるので、npm i cnpmだとまたエラーになりますね。

そこでnpm install -g cnpm --registry=https://registry.npm.taobao.org 、そこにある淘宝網のミラーからダウンロードすると、cnpmが正常にダウンロードされます。

最後にcnpm install node-sass -saveと入力すると、npm run devがようやく起動!!!!