gpt4 book ai didi

node.js - 更新了我系统上的 Node ,现在 grunt 不会在 npm 项目中运行

转载 作者:太空宇宙 更新时间:2023-11-04 00:53:43 30 4
gpt4 key购买 nike

我最近将计算机上的 Node 更新为 0.12.4。这似乎对我在 Node.js Express.js 中工作的项目产生了一些影响。据我所知,我现在运行的 Node 版本和 node_modules 之间似乎存在某种兼容性问题。我使用 Git 返回到该项目的先前版本(运行良好的版本),但现在它们也不起作用。

我的电脑正在运行:OSX 优胜美地 10.10.3 Node :0.12.4npm:2.11.3

我的 package.json 文件中的项目依赖项:

    "dependencies": {
"body-parser": "~1.8.1",
"cookie-parser": "~1.3.3",
"debug": "~2.0.0",
"express": "~4.9.0",
"grunt": "^0.4.5",
"grunt-sass": "^0.17.0",
"jade": "~1.6.0",
"morgan": "~1.3.0",
"node-sass": "^1.2.3",
"serve-favicon": "~2.1.3"
},
"devDependencies": {
"grunt-contrib-watch": "^0.6.1"
}

问题:当我在终端中运行 grunt 时,我收到错误消息:

    Loading "sass.js" tasks...ERROR
>> Error: Cannot find module 'node-sass'
Warning: Task "sass" not found. Use --force to continue.

因此,我删除了所有 node_modules 并在终端中运行 npm install ,但出现了更多错误:

    Error: Module did not self-register.
at Error (native)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/Users/sheynawatkins/dev/node/lola/node_modules/node-sass/lib/index.js:181:15)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
npm ERR! Darwin 14.3.0
npm ERR! argv "node" "/usr/local/bin/npm" "install"
npm ERR! node v0.12.4
npm ERR! npm v2.11.3
npm ERR! code ELIFECYCLE

npm ERR! node-sass@1.2.3 postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-sass@1.2.3 postinstall script 'node scripts/build.js'.
npm ERR! This is most likely a problem with the node-sass package,
npm ERR! not with npm itself.

我应该做什么?

最佳答案

您使用的是 node-sass 的旧版本(^1.2.3,而当前版本是 3.2.0),因此请尝试安装更新的版本(安装得很好)我使用的是 Node 0.12):

$ npm i node-sass@latest --save

关于node.js - 更新了我系统上的 Node ,现在 grunt 不会在 npm 项目中运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31043555/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com