Module build failed: Error: ENOENT: no such file or directory, scandir ‘*node_modules/node-sass/vendor’

14. December 2017 Laravel 0

在laravel中,运行npm install,一切正常,但在运行npm run dev 时候报错,如下:

在错误中,我发现Module build failed: Error: ENOENT: no such file or directory, scandir ‘/home/wwwroot/default/laravel5.5/node_modules/node-sass/vendor’这句话,看到目录下确实没有这个文件夹,然后执行

npm rebuild node-sass
npm run dev

然后再运行就可以,具体造成此问题的原因不知,再次运行 npm run dev 就可了。

ERROR in ./node_modules/css-loader?{"url":true,"sourceMap":false,"importLoaders":1}!./node_modules/postcss-loader/lib?{"sourceMap":true,"ident":"postcss","plugins":[null]}!./node_modules/resolve-url-loader?{"sourceMap":true,"root":"/home/wwwroot/default/laravel5.5/node_modules"}!./node_modules/sass-loader/lib/loader.js?{"precision":8,"outputStyle":"expanded","sourceMap":true}!./resources/assets/sass/app.scss
Module build failed: Error: ENOENT: no such file or directory, scandir '/home/wwwroot/default/laravel5.5/node_modules/node-sass/vendor'
 at Object.fs.readdirSync (fs.js:904:18)
 at Object.getInstalledBinaries (/home/wwwroot/default/laravel5.5/node_modules/node-sass/lib/extensions.js:128:13)
 at foundBinariesList (/home/wwwroot/default/laravel5.5/node_modules/node-sass/lib/errors.js:20:15)
 at foundBinaries (/home/wwwroot/default/laravel5.5/node_modules/node-sass/lib/errors.js:15:5)
 at Object.module.exports.missingBinary (/home/wwwroot/default/laravel5.5/node_modules/node-sass/lib/errors.js:45:5)
 at module.exports (/home/wwwroot/default/laravel5.5/node_modules/node-sass/lib/binding.js:15:30)
 at Object.<anonymous> (/home/wwwroot/default/laravel5.5/node_modules/node-sass/lib/index.js:14:35)
 at Module._compile (module.js:635:30)
 at Object.Module._extensions..js (module.js:646:10)
 at Module.load (module.js:554:32)
 at tryModuleLoad (module.js:497:12)
 at Function.Module._load (module.js:489:3)
 at Module.require (module.js:579:17)
 at require (internal/module.js:11:18)
 at Object.<anonymous> (/home/wwwroot/default/laravel5.5/node_modules/sass-loader/lib/loader.js:3:14)
 at Module._compile (module.js:635:30)
 at Object.Module._extensions..js (module.js:646:10)
 at Module.load (module.js:554:32)
 at tryModuleLoad (module.js:497:12)
 at Function.Module._load (module.js:489:3)
 at Module.require (module.js:579:17)
 at require (internal/module.js:11:18)
 at loadLoader (/home/wwwroot/default/laravel5.5/node_modules/loader-runner/lib/loadLoader.js:13:17)
 at iteratePitchingLoaders (/home/wwwroot/default/laravel5.5/node_modules/loader-runner/lib/LoaderRunner.js:169:2)
 at iteratePitchingLoaders (/home/wwwroot/default/laravel5.5/node_modules/loader-runner/lib/LoaderRunner.js:165:10)
 at /home/wwwroot/default/laravel5.5/node_modules/loader-runner/lib/LoaderRunner.js:173:18
 at loadLoader (/home/wwwroot/default/laravel5.5/node_modules/loader-runner/lib/loadLoader.js:36:3)
 at iteratePitchingLoaders (/home/wwwroot/default/laravel5.5/node_modules/loader-runner/lib/LoaderRunner.js:169:2)
 at iteratePitchingLoaders (/home/wwwroot/default/laravel5.5/node_modules/loader-runner/lib/LoaderRunner.js:165:10)
 at /home/wwwroot/default/laravel5.5/node_modules/loader-runner/lib/LoaderRunner.js:173:18
 @ ./resources/assets/sass/app.scss 4:14-266
 @ multi ./resources/assets/js/app.js ./resources/assets/sass/app.scss

ERROR in ./resources/assets/sass/app.scss
Module build failed: ModuleBuildError: Module build failed: Error: ENOENT: no such file or directory, scandir '/home/wwwroot/default/laravel5.5/node_modules/node-sass/vendor'
 at Object.fs.readdirSync (fs.js:904:18)
 at Object.getInstalledBinaries (/home/wwwroot/default/laravel5.5/node_modules/node-sass/lib/extensions.js:128:13)
 at foundBinariesList (/home/wwwroot/default/laravel5.5/node_modules/node-sass/lib/errors.js:20:15)
 at foundBinaries (/home/wwwroot/default/laravel5.5/node_modules/node-sass/lib/errors.js:15:5)
 at Object.module.exports.missingBinary (/home/wwwroot/default/laravel5.5/node_modules/node-sass/lib/errors.js:45:5)
 at module.exports (/home/wwwroot/default/laravel5.5/node_modules/node-sass/lib/binding.js:15:30)
 at Object.<anonymous> (/home/wwwroot/default/laravel5.5/node_modules/node-sass/lib/index.js:14:35)
 at Module._compile (module.js:635:30)
 at Object.Module._extensions..js (module.js:646:10)
 at Module.load (module.js:554:32)
 at tryModuleLoad (module.js:497:12)
 at Function.Module._load (module.js:489:3)
 at Module.require (module.js:579:17)
 at require (internal/module.js:11:18)
 at Object.<anonymous> (/home/wwwroot/default/laravel5.5/node_modules/sass-loader/lib/loader.js:3:14)
 at Module._compile (module.js:635:30)
 at Object.Module._extensions..js (module.js:646:10)
 at Module.load (module.js:554:32)
 at tryModuleLoad (module.js:497:12)
 at Function.Module._load (module.js:489:3)
 at Module.require (module.js:579:17)
 at require (internal/module.js:11:18)
 at loadLoader (/home/wwwroot/default/laravel5.5/node_modules/loader-runner/lib/loadLoader.js:13:17)
 at iteratePitchingLoaders (/home/wwwroot/default/laravel5.5/node_modules/loader-runner/lib/LoaderRunner.js:169:2)
 at iteratePitchingLoaders (/home/wwwroot/default/laravel5.5/node_modules/loader-runner/lib/LoaderRunner.js:165:10)
 at /home/wwwroot/default/laravel5.5/node_modules/loader-runner/lib/LoaderRunner.js:173:18
 at loadLoader (/home/wwwroot/default/laravel5.5/node_modules/loader-runner/lib/loadLoader.js:36:3)
 at iteratePitchingLoaders (/home/wwwroot/default/laravel5.5/node_modules/loader-runner/lib/LoaderRunner.js:169:2)
 at iteratePitchingLoaders (/home/wwwroot/default/laravel5.5/node_modules/loader-runner/lib/LoaderRunner.js:165:10)
 at /home/wwwroot/default/laravel5.5/node_modules/loader-runner/lib/LoaderRunner.js:173:18
 at loadLoader (/home/wwwroot/default/laravel5.5/node_modules/loader-runner/lib/loadLoader.js:36:3)
 at iteratePitchingLoaders (/home/wwwroot/default/laravel5.5/node_modules/loader-runner/lib/LoaderRunner.js:169:2)
 at iteratePitchingLoaders (/home/wwwroot/default/laravel5.5/node_modules/loader-runner/lib/LoaderRunner.js:165:10)
 at /home/wwwroot/default/laravel5.5/node_modules/loader-runner/lib/LoaderRunner.js:173:18
 at loadLoader (/home/wwwroot/default/laravel5.5/node_modules/loader-runner/lib/loadLoader.js:36:3)
 at iteratePitchingLoaders (/home/wwwroot/default/laravel5.5/node_modules/loader-runner/lib/LoaderRunner.js:169:2)
 at runLoaders (/home/wwwroot/default/laravel5.5/node_modules/webpack/lib/NormalModule.js:195:19)
 at /home/wwwroot/default/laravel5.5/node_modules/loader-runner/lib/LoaderRunner.js:364:11
 at /home/wwwroot/default/laravel5.5/node_modules/loader-runner/lib/LoaderRunner.js:170:18
 at loadLoader (/home/wwwroot/default/laravel5.5/node_modules/loader-runner/lib/loadLoader.js:27:11)
 at iteratePitchingLoaders (/home/wwwroot/default/laravel5.5/node_modules/loader-runner/lib/LoaderRunner.js:169:2)
 at iteratePitchingLoaders (/home/wwwroot/default/laravel5.5/node_modules/loader-runner/lib/LoaderRunner.js:165:10)
 at /home/wwwroot/default/laravel5.5/node_modules/loader-runner/lib/LoaderRunner.js:173:18
 at loadLoader (/home/wwwroot/default/laravel5.5/node_modules/loader-runner/lib/loadLoader.js:36:3)
 at iteratePitchingLoaders (/home/wwwroot/default/laravel5.5/node_modules/loader-runner/lib/LoaderRunner.js:169:2)
 at iteratePitchingLoaders (/home/wwwroot/default/laravel5.5/node_modules/loader-runner/lib/LoaderRunner.js:165:10)
 at /home/wwwroot/default/laravel5.5/node_modules/loader-runner/lib/LoaderRunner.js:173:18
 at loadLoader (/home/wwwroot/default/laravel5.5/node_modules/loader-runner/lib/loadLoader.js:36:3)
 at iteratePitchingLoaders (/home/wwwroot/default/laravel5.5/node_modules/loader-runner/lib/LoaderRunner.js:169:2)
 at iteratePitchingLoaders (/home/wwwroot/default/laravel5.5/node_modules/loader-runner/lib/LoaderRunner.js:165:10)
 at /home/wwwroot/default/laravel5.5/node_modules/loader-runner/lib/LoaderRunner.js:173:18
 at loadLoader (/home/wwwroot/default/laravel5.5/node_modules/loader-runner/lib/loadLoader.js:36:3)
 at iteratePitchingLoaders (/home/wwwroot/default/laravel5.5/node_modules/loader-runner/lib/LoaderRunner.js:169:2)
 at runLoaders (/home/wwwroot/default/laravel5.5/node_modules/loader-runner/lib/LoaderRunner.js:362:2)
 at NormalModule.doBuild (/home/wwwroot/default/laravel5.5/node_modules/webpack/lib/NormalModule.js:182:3)
 at NormalModule.build (/home/wwwroot/default/laravel5.5/node_modules/webpack/lib/NormalModule.js:275:15)
 at Compilation.buildModule (/home/wwwroot/default/laravel5.5/node_modules/webpack/lib/Compilation.js:151:10)
 at moduleFactory.create (/home/wwwroot/default/laravel5.5/node_modules/webpack/lib/Compilation.js:456:10)
 at factory (/home/wwwroot/default/laravel5.5/node_modules/webpack/lib/NormalModuleFactory.js:241:5)
 at applyPluginsAsyncWaterfall (/home/wwwroot/default/laravel5.5/node_modules/webpack/lib/NormalModuleFactory.js:94:13)
 at /home/wwwroot/default/laravel5.5/node_modules/tapable/lib/Tapable.js:268:11
 at NormalModuleFactory.params.normalModuleFactory.plugin (/home/wwwroot/default/laravel5.5/node_modules/webpack/lib/CompatibilityPlugin.js:52:5)
 at NormalModuleFactory.applyPluginsAsyncWaterfall (/home/wwwroot/default/laravel5.5/node_modules/tapable/lib/Tapable.js:272:13)
 at resolver (/home/wwwroot/default/laravel5.5/node_modules/webpack/lib/NormalModuleFactory.js:69:10)
 at process.nextTick (/home/wwwroot/default/laravel5.5/node_modules/webpack/lib/NormalModuleFactory.js:194:7)
 at _combinedTickCallback (internal/process/next_tick.js:131:7)
 at process._tickCallback (internal/process/next_tick.js:180:9)
 @ ./resources/assets/sass/app.scss
 @ multi ./resources/assets/js/app.js ./resources/assets/sass/app.scss
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! @ development: `cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
npm ERR! Exit status 2
npm ERR! 
npm ERR! Failed at the @ development 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! /root/.npm/_logs/2017-12-14T04_54_09_092Z-debug.log