gpt4 book ai didi

node.js - 如何解决 "Cannot find module ' gulp-util'"的问题?

转载 作者:行者123 更新时间:2023-12-02 17:28:24 24 4
gpt4 key购买 nike

今天早上我已经花了一个小时查看现有的 SO 答案以及互联网上的其他地方。

当我运行 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 并进行了尝试,确保删除 gulp 的全局安装。仍然没有运气。 ( https://github.com/gulpjs/gulp/blob/master/docs/getting-started.md )

npm rm --global gulp

我可以在远程环境中运行 gulp,它工作得很好,所以它似乎是一个本地配置问题。

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

包.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": "git@crystal.github.com:crystalcommerce/pos-frontend.git"
},
"author": "John Doe",
"license": "ISC"
}

gulp文件.js

var gulp = require('gulp');

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

重现错误的步骤

rm -rf node_modules/
npm install
gulp

最佳答案

看起来我有一个旧版本的 gulp,当我调用 npm rm --global gulp 时它没有被删除。

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

关于node.js - 如何解决 "Cannot find module ' gulp-util'"的问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36721082/

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