【问题标题】:Ionic - Error: Cannot find module 'gulp-sass'离子 - 错误:找不到模块'gulp-sass'
【发布时间】:2018-07-13 21:52:27
【问题描述】:

我有一个 Ionic v1 应用程序,当我尝试通过 gulp 命令运行该应用程序时,我收到以下错误:

Error: Cannot find module 'gulp-sass' from '/Users/bertcarremans/Tuintalent/code'
at Function.module.exports [as sync] (/Users/bertcarremans/Tuintalent/code/node_modules/resolve/lib/sync.js:40:15)
at requireFn (/Users/bertcarremans/Tuintalent/code/node_modules/gulp-load-plugins/index.js:74:25)
at Object.get [as sass] (/Users/bertcarremans/Tuintalent/code/node_modules/gulp-load-plugins/index.js:117:41)
at Gulp.<anonymous> (/Users/bertcarremans/Tuintalent/code/tasks/config/compile.js:30:18)
at module.exports (/Users/bertcarremans/Tuintalent/code/node_modules/orchestrator/lib/runTask.js:34:7)
at Gulp.Orchestrator._runTask (/Users/bertcarremans/Tuintalent/code/node_modules/orchestrator/index.js:273:3)
at Gulp.Orchestrator._runStep (/Users/bertcarremans/Tuintalent/code/node_modules/orchestrator/index.js:214:10)
at Gulp.Orchestrator.start (/Users/bertcarremans/Tuintalent/code/node_modules/orchestrator/index.js:134:8)
at /Users/bertcarremans/Tuintalent/code/node_modules/gulp-sequence/index.js:68:12
at apply (/Users/bertcarremans/Tuintalent/code/node_modules/thunks/index.js:355:38)

所以我按照post 中提到的说明操作并尝试了npm update 但后来我收到以下错误:

gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/bertcarremans/Tuintalent/code/node_modules/node-gyp/lib/build.js:258:23)
gyp ERR! stack     at emitTwo (events.js:126:13)
gyp ERR! stack     at ChildProcess.emit (events.js:214:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
gyp ERR! System Darwin 16.7.0
gyp ERR! command "/usr/local/bin/node" "/Users/bertcarremans/Tuintalent/code/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /Users/bertcarremans/Tuintalent/code/node_modules/node-sass
gyp ERR! node -v v8.9.4
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok 
Build failed with error code: 1
npm WARN tuintalent@1.1.1 No repository field.
npm WARN tuintalent@1.1.1 No license field.
npm WARN The package gulp-concat is included as both a dev and production dependency.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-sass@3.13.1 postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the node-sass@3.13.1 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

我的这个应用程序的环境是: cli 包:(/usr/local/lib/node_modules)

@ionic/cli-utils  : 1.19.1
ionic (Ionic CLI) : 3.19.1

全局包:

cordova (Cordova CLI) : 8.0.0 
Gulp CLI              : CLI version 3.9.1 Local version 3.9.1

本地包:

Cordova Platforms : android 7.0.0 ios 4.5.4
Ionic Framework   : ionic1 1.3.2

系统:

ios-deploy : 1.9.0 
ios-sim    : 6.1.2 
Node       : v8.9.4
npm        : 5.6.0 
OS         : macOS Sierra
Xcode      : Xcode 9.2 Build version 9C40b 

环境变量:

ANDROID_HOME : not set

杂项:

backend : pro

删除node_modules 并执行npm install 也会产生其他错误。

gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/bertcarremans/Tuintalent/code/node_modules/node-gyp/lib/build.js:258:23)
gyp ERR! stack     at emitTwo (events.js:126:13)
gyp ERR! stack     at ChildProcess.emit (events.js:214:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
gyp ERR! System Darwin 16.7.0
gyp ERR! command "/usr/local/bin/node" "/Users/bertcarremans/Tuintalent/code/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /Users/bertcarremans/Tuintalent/code/node_modules/node-sass
gyp ERR! node -v v8.9.4
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok 
Build failed with error code: 1
npm WARN tuintalent@1.1.1 No repository field.
npm WARN tuintalent@1.1.1 No license field.
npm WARN The package gulp-concat is included as both a dev and production dependency.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-sass@3.13.1 postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the node-sass@3.13.1 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

有人知道如何解决这个问题吗?谢谢!

【问题讨论】:

    标签: node.js ionic-framework sass gulp


    【解决方案1】:

    只需在您的根文件夹中执行npm update 然后npm install gulp-sass --save-dev,然后在运行时您应该不会有任何问题。

    或者做

    rm -rf node_modules/
    npm install
    

    【讨论】:

    • npm 更新没有像我上面提到的那样工作。删除 node_modules 并执行 npm install 会导致其他错误。我已经编辑了我的问题以显示这些错误。
    • 嗨@BertCarremans 你最终做了什么来解决这个问题?
    【解决方案2】:

    对于 OP 来说已经很晚了——但是,node-gyp make 错误意味着“节点正在编译模块的 c/c++ 的本机代码并且失败了”——在我最近遇到的类似情况下,MacOS 构建工具无效,可以当 XCODE 更新但命令行工具(c++ 编译器等)尚未准备好使用时导致。

    对于 MacOS 上 node-gyp 问题的典型解决方案,该模块有不错的文档 - MacOS node-gyp fixes

    【讨论】:

      猜你喜欢
      • 2016-01-23
      • 2018-10-19
      • 1970-01-01
      • 2018-05-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多