解决node-sass-called-fsevents-install-error

背景

Windows环境下运行某个vue全家桶做的项目,git clone 后,运行cnpm install报错,运行npm run dev后也报错。初步判断报错原因是node-sass没有编译通过导致。

报错情况

cnpm install

1
2
3
4
5
6
7
8
9
10
11
12
13
/ Installing inherits@^2.0.1platform unsupported karma@1.3.0 › chokidar@1.6.1 › fsevents@1.0.17 Package require os(darwin) not compatible with your platform(win32)
[fsevents@^1.0.0] optional install error: Package require os(darwin) not compatible with your platform(win32)
path.js:7
throw new TypeError('Path must be a string. Received ' + inspect(path));
^
TypeError: Path must be a string. Received undefined
at assertPath (path.js:7:11)
at Object.join (path.js:468:7)
at findSuitableTempDirectory (F:\code\hxdd\live\live-web\node_modules\.2.27.1@chromedriver\install.js:93:30)
at Object.<anonymous> (F:\code\hxdd\live\live-
npminstall version: 2.10.0
npminstall args: E:\IDE\node\Nodist\v-x64\7.0.0\node.exe

npm run dev

1
2
3
4
5
6
7
8
9
10
11
ERROR in %1 is not a valid Win32 application.
\\?\F:\code\hxdd\live\live-web\node_modules\.4.2.0@node-sass\vendor\win32-x64-51\binding.node
@ ./src/scss/app.scss 4:14-135 13:2-17:4 14:20-141
ERROR in %1 is not a valid Win32 application.
\\?\F:\code\hxdd\live\live-web\node_modules\.4.2.0@node-sass\vendor\win32-x64-51\binding.node
@ ./~/.1.0.0@vue-style-loader!./~/.0.25.0@css-loader!./~/.10.0.2@vue-loader/lib/style-rewriter.js?id=data-v-580e2079!./~/.4.1.1@sass-loader!./~/.10.0.2@vue-loader/lib/selector.js?type=styles&index=0!./src/App.vue 4:14-279 13:2-17:4 14:20-285
ERROR in %1 is not a valid Win32 application.
\\?\F:\code\hxdd\live\live-web\node_modules\.4.2.0@node-sass\vendor\win32-x64-51\binding.node
@ ./~/.1.0.0@vue-style-loader!./~/.0.25.0@css-loader!./~/.10.0.2@vue-loader/lib/style-rewriter.js?id=data-v-bab9d198!./~/.4.1.1@sass-loader!./~/.10.0.2@vue-loader/lib/selector.js?type=styles&index=0!./src/views/web/Index.vue 4:14-305 13:2-17:4 14:20-311

解决

  • 确认先安装一下最新版node-sass(非必需)
1
npm install sass-loader node-sass webpack --save-dev
  • 本地编译node-sass
1
cnpm rebuild node-sass

到此为止,应该可以了。

哦对了,我的平台版本是 Window10 x64