我正在尝试从 grunt-contrib-sass 切换到 grunt-sass,但是在 grunt 包装器模块中遇到了与 node-sass 相关的构建错误。到目前为止,我已经将节点从 0.10.40 升级到 0.12.7 并切换到 Python 2.7 以绕过其他一些,但这就是剩下的:
$ npm install
> node-sass@1.0.3 install /var/www/html/example.com/www/node_modules/grunt-sass/node_modules/node-sass
> node build.js
child_process: customFds option is deprecated, use stdio instead.
make: Entering directory `/var/www/html/example.com/www/node_modules/grunt-sass/node_modules/node-sass/build'
CXX(target) Release/obj.target/binding/binding.o
cc1plus: error: unrecognized command line option "-std=c++11"
cc1plus: error: unrecognized command line option "-std=c++11"
make: *** [Release/obj.target/binding/binding.o] Error 1
make: Leaving directory `/var/www/html/example.com/www/node_modules/grunt-sass/node_modules/node-sass/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:269:23)
gyp ERR! stack at ChildProcess.emit (events.js:110:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:1074:12)
gyp ERR! System Linux 2.6.18-274.18.1.el5.centos.plus
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /var/www/html/example.com/www/node_modules/grunt-sass/node_modules/node-sass
gyp ERR! node -v v0.12.7
gyp ERR! node-gyp -v v2.0.1
gyp ERR! not ok
Build failed
npm ERR! Linux 2.6.18-274.18.1.el5.centos.plus
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
npm ERR! node v0.12.7
npm ERR! npm v2.11.3
npm ERR! code ELIFECYCLE
npm ERR! node-sass@1.0.3 install: `node build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-sass@1.0.3 install script 'node build.js'.
npm ERR! This is most likely a problem with the node-sass package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node build.js
npm ERR! You can get their info via:
npm ERR! npm owner ls node-sass
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /var/www/html/example.com/www/npm-debug.log
附加版本信息:
$ node -v
v0.12.7
$ node -v
v0.12.7
$ npm -v
2.11.3
$ cat /etc/redhat-release
CentOS release 5.11 (Final)
我在解决 Node.js 兼容性问题方面有点不够深入。虽然这是在共享的开发环境中,但我愿意尝试任何没有大规模全球变化的事情,比如升级操作系统。
更新:我已经通过从本地 node_modules 文件夹中手动删除 node-sass 和 node-gyp 解决了这个问题。之后运行 npm install 运行没有错误。我认为这些模块是早期尝试遗留下来的(很可能是在升级 node.js 和 Python 之前)。