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

标签 node.js npm node-sass

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

我的电脑正在运行: OSX 优胜美地 10.10.3 Node :0.12.4 npm: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/

相关文章:

node.js - WSL 上的 npm install node-sass@4.14.1 错误

css - 使用 --watch 标志时 Node-sass 将不起作用

javascript - 如何在mean/angular js中检测文件是否从客户端下载成功

node.js - 如何为 sequelize 多对多关联方法创建类型安全,例如(setModels 等)

javascript - 庆典 : nodemon command not found windows 10

linux - 在位置 2 安装带有 NVM 不匹配支架的 NPM

mysql - Typeahead.js 未填充搜索框

node.js - 错误处理不同类型的错误

node.js - 在 Mac : inotify@1. 4.1 中不受支持

node.js - yarn 尝试安装 node-sass 的问题