2016-04-19 118 views
0

我已經花了一個小時,今天早上已經在尋找現有的SO答案以及在互聯網上的其他地方。如何解決「無法找到模塊'gulp-util'」的問題?

當我運行gulp,我得到以下錯誤

➜ qwer git:(master) ✗ gulp 
module.js:341 
    throw err; 
    ^

Error: Cannot find module 'gulp-util' 
    at Function.Module._resolveFilename (module.js:339:15) 
    at Function.Module._load (module.js:290:25) 
    at Module.require (module.js:367:17) 
    at require (internal/module.js:16:19) 
    at Object.<anonymous> (/usr/local/lib/node_modules/gulp/bin/gulp.js:4:13) 
    at Module._compile (module.js:413:34) 
    at Object.Module._extensions..js (module.js:422:10) 
    at Module.load (module.js:357:32) 
    at Function.Module._load (module.js:314:12) 
    at Function.Module.runMain (module.js:447:10) 

我按照建議再次清除出node_modulesnpm install;沒有骰子。

我已經安裝了舊版本的node/npm並嘗試過,確保刪除全球安裝的吞噬。仍然沒有運氣。 (https://github.com/gulpjs/gulp/blob/master/docs/getting-started.md

npm rm --global gulp 

我可以在遠程環境中運行一飲而盡,它工作得很好,所以這似乎是一個本地配置的問題。

➜ qwer git:(master) ✗ node -v 
v5.10.1 
➜ qwer git:(master) ✗ npm -v 
3.8.3 

的package.json

{ 
    "name": "qwer", 
    "version": "1.0.0", 
    "description": "asdlf kjalsdk fjalsdk jfla", 
    "main": "config/gulpfile.js", 
    "dependencies": { 
    "babel-preset-es2015": "^6.6.0", 
    "babelify": "^7.2.0", 
    "backbone": "^1.3.3", 
    "del": "^2.2.0", 
    "gulp": "^3.9.1", 
    "browserify": "^13.0.0", 
    "gulp-concat": "^2.6.0", 
    "gulp-rename": "^1.2.2", 
    "gulp-sass": "^2.2.0", 
    "gulp-sourcemaps": "^1.6.0", 
    "gulp-uglify": "^1.5.3", 
    "jquery": "^2.2.3", 
    "jstify": "^0.14.0", 
    "underscore": "^1.8.3", 
    "vinyl-buffer": "^1.0.0", 
    "moment": "^2.13.0", 
    "yargs": "^4.6.0", 
    "vinyl-source-stream": "^1.1.0" 
    }, 
    "devDependencies": { 
    "browser-sync": "^2.12.3", 
    "gulp": "^3.9.1" 
    }, 
    "scripts": { 
    "test": "echo \"Error: no test specified\" && exit 1" 
    }, 
    "repository": { 
    "type": "git", 
    "url": "[email protected]:crystalcommerce/pos-frontend.git" 
    }, 
    "author": "John Doe", 
    "license": "ISC" 
} 

gulpfile.js

var gulp = require('gulp'); 

gulp.task('default', function() { 
    // place code for your default task here 
}); 

步驟來重現錯誤

rm -rf node_modules/ 
npm install 
gulp 
+0

同樣的問題,但補充答案https://stackoverflow.com/questions/21406738/cant-get-gulp-to-run-cannot-find-module-gulp-util – dskrvk

回答

0

看來我有一個老版本一飲而盡的那WASN」我打電話給012時不會被刪除。

which gulp 
➜ /usr/local/bin/gulp 

# remove old version; not sure where this came from; perhaps brew? 
rm /usr/local/bin/gulp 

which gulp 
➜ /Users/davidvezzani/.nvm/versions/node/v5.10.1/bin/gulp 

# for good measure 
rm /Users/davidvezzani/.nvm/versions/node/v5.10.1/bin/gulp 

npm install --global gulp-cli 

which gulp 
➜ /Users/davidvezzani/.nvm/versions/node/v5.10.1/bin/gulp 

gulp 

[07:15:22] Using gulpfile ~/reliacode/crystal_commerce/qwer/gulpfile.js 
[07:15:22] Starting 'default'... 
[07:15:22] Finished 'default' after 71 μs 
0

嘗試添加npm-shrink-wrap強制鎖定NPM包JSON使用特定版本一飲而盡無論什麼有在故宮全局緩存,或者你可以嘗試使用清潔的npm clean cache NPM緩存文件夾。

相關問題