11

我正在运行 OSX 10.11.1 并尝试npm install在 package.json 中包含 node-sass 依赖项的项目:

“依赖项”:{“node-sass”:“^3.4.2”}

我正在运行 NPM 版本 2.14.7 和节点版本 4.2.3。当我运行npm install或 npm时rebuild node-sass,我得到以下错误输出:

> node-sass@2.1.1 安装后 /Users/markroper/code/mktg/node_modules/gulp-sass/node_modules/node-sass
> 节点脚本/build.js
gyp: /Users/markroper/.node-gyp/4.2.3/common.gypi not found (cwd: /Users/markroper/code/mktg/node_modules/gulp-sass/node_modules/node-sass) 同时阅读包括绑定.gyp 尝试加载 binding.gyp
吉普错误!配置错误
吉普错误!堆栈错误:`gyp` 失败,退出代码:1
吉普错误!ChildProcess.onCpExit 的堆栈(/Users/markroper/code/mktg/node_modules/gulp-sass/node_modules/node-sass/node_modules/pangyp/lib/configure.js:346:16)
吉普错误!堆栈在 emitTwo (events.js:87:13)
吉普错误!ChildProcess.emit (events.js:172:7) 的堆栈
吉普错误!堆栈在 Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
吉普错误!系统达尔文 15.0.0
吉普错误!命令“/usr/local/bin/node”“/Users/markroper/code/mktg/node_modules/gulp-sass/node_modules/node-sass/node_modules/pangyp/bin/node-gyp”“重建”
吉普错误!cwd /Users/markroper/code/mktg/node_modules/gulp-sass/node_modules/node-sass
吉普错误!节点-v v4.2.3
吉普错误!pangyp -v v2.3.3
吉普错误!不好
构建失败

有没有人用这些版本解决这个错误?

4

3 回答 3

12

安装时添加 --unsafe-perm 标志

对于 linux/mac

sudo npm install --unsafe-perm -g node-sass

对于 windows 环境,点击相同的命令删除 sudo

于 2019-04-03T11:44:27.933 回答
10

Node-sass 不适用于较新的节点版本。您可以通过在安装带有npm install.

我建议为此使用 Node Version Manager (nvm),安装说明可以在Github上找到。安装 nvm 后,nvm install v0.12.7您可以验证运行的节点版本node -v如果返回 v0.12.7,您应该可以运行 npm install。(确保这样做是同一个终端窗口)

于 2016-05-18T12:25:38.410 回答
1

node-sass现在是一个弃用的包。最好避免使用它并安装sass包。

npm install sass

它在最新版本的 Node 和 npm 上运行良好,它是 Dart Sass 的发行版,目前是推荐的实现。

于 2021-10-15T09:42:36.907 回答