npm: no such file or directory, scandir '.../node_modules/node-sass/vendor'

在启动vue工程项目时报错:

npm install
npm run dev
错误日志:

huyikangdeMacBook-Pro:vbap-widgets kangkang$ npm run dev

> [email protected] dev /Users/kangkang/vbap-widgets
> node build/dev-server.js

[HPM] Proxy created: function (path, req) {
          let match = path.match('^/(me|sec|log|api|query|data|results|table|export|quick|mobile|rules|share|vbap-docs)');
          // if (match) {
          //   console.log('proxy path:', path)
          // }
          return match
        }  ->  http://10.0.2.12:8099/vbap3
[HPM] Subscribed to http-proxy events:  [ 'error', 'close' ]
> Starting dev server...


 ERROR  Failed to compile with 9 errors                                上午9:36:42

 error  in ./src/theme/index.scss

Module build failed: Error: ENOENT: no such file or directory, scandir '/Users/kangkang/vbap-widgets/node_modules/node-sass/vendor'
    at Object.fs.readdirSync (fs.js:904:18)
    at Object.getInstalledBinaries (/Users/kangkang/vbap-widgets/node_modules/node-sass/lib/extensions.js:127:13)
    at foundBinariesList (/Users/kangkang/vbap-widgets/node_modules/node-sass/lib/errors.js:20:15)
    at foundBinaries (/Users/kangkang/vbap-widgets/node_modules/node-sass/lib/errors.js:15:5)
    at Object.module.exports.missingBinary (/Users/kangkang/vbap-widgets/node_modules/node-sass/lib/errors.js:45:5)
    at module.exports (/Users/kangkang/vbap-widgets/node_modules/node-sass/lib/binding.js:15:30)
    at Object. (/Users/kangkang/vbap-widgets/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. (/Users/kangkang/vbap-widgets/node_modules/sass-loader/lib/loader.js:3:14)
    at Module._compile (module.js:635:30)

 @ ./src/theme/index.scss 4:14-145 13:3-17:5 14:22-153
 @ ./src/main.js
 @ multi ./build/dev-client ./src/main.js

 error  in ./src/app/App.vue
显示找不到 node_modules/node-sass/vendor 模块。去文件夹一看,还真的是没有,应该是在安装全局依赖的时候,没有安装到vendor,通过rebuild命令重新安装一下就可以啦。

解决办法,运行:npm rebuild node-sass

huyikangdeMacBook-Pro:vbap-widgets kangkang$ npm rebuild node-sass

> [email protected] install /Users/kangkang/vbap-widgets/node_modules/node-sass
> node scripts/install.js

Downloading binary from https://github.com/sass/node-sass/releases/download/v4.6.1/darwin-x64-57_binding.node
Download complete  ⸩ ⠋ :
Binary saved to /Users/kangkang/vbap-widgets/node_modules/node-sass/vendor/darwin-x64-57/binding.node
Caching binary to /Users/kangkang/.npm/node-sass/4.6.1/darwin-x64-57_binding.node

> [email protected] postinstall /Users/kangkang/vbap-widgets/node_modules/node-sass
> node scripts/build.js

Binary found at /Users/kangkang/vbap-widgets/node_modules/node-sass/vendor/darwin-x64-57/binding.node
Testing binary
Binary is fine
[email protected] /Users/kangkang/vbap-widgets/node_modules/node-sass
成功,去文件夹下查看,确实有了vedor文件夹,再 npm run dev启动工程就可以啦。




你可能感兴趣的:(Nodejs)