簡體   English   中英

離子 - 錯誤:找不到模塊“gulp-sass”

[英]Ionic - Error: Cannot find module 'gulp-sass'

我有一個 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)

所以我按照這篇文章中提到的說明嘗試了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.

有人知道如何解決這個問題嗎? 謝謝!

對於 OP 來說相當晚了 - 但是,node-gyp make 錯誤意味着“節點正在編譯模塊的 c/c++ 本地代碼並失敗” - 在我最近遇到的類似情況下,MacOS 構建工具無效,可能是在以下情況下引起的XCODE 已更新,但命令行工具(c++ 編譯器等)尚未准備好使用。

對於 MacOS 上 node-gyp 問題的典型解決方案,該模塊有不錯的文檔 - MacOS node-gyp 修復

只需執行npm update然后npm install gulp-sass --save-dev在您的根文件夾中,然后當您運行時,您應該沒有任何問題。

或做

rm -rf node_modules/
npm install

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM