Gulp -v在旧项目中不起作用

时间:2018-08-18 09:19:18

标签: node.js npm gulp

gulp serve命令需要旧版本的node,因此我使用nvm进行更改,然后gulp -v命令停止工作:

npm版本

npm -v
5.6.0

节点版本

nodejs -v
8.9.4

gulp版本

  $ gulp -v
[11:57:57] CLI version 3.9.1
[11:57:57] Local version 4.0.0
$ node -v
v9.11.1
$ nvm use 7.7.3
Now using node v7.7.3 (npm v4.1.2)
$ node -v
v7.7.3
$ gulp -v
module.js:540
    throw err;
    ^

Error: Cannot find module 'gulp-util'
    at Function.Module._resolveFilename (module.js:538:15)
    at Function.Module._load (module.js:468:25)
    at Module.require (module.js:587:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/usr/lib/nodejs/gulp/bin/gulp.js:4:13)
    at Module._compile (module.js:643:30)
    at Object.Module._extensions..js (module.js:654:10)
    at Module.load (module.js:556:32)
    at tryModuleLoad (module.js:499:12)
    at Function.Module._load (module.js:491:3)

package.json:

{
  "name": "a",
  "version": "1.0.0",
  "description": "A",
  "engines": {
    "node": ">= 0.8.4"
  },
    "devDependencies": {
"bower": "^1.3.12",
"compass": "^0.1.1",
"del": "^1.1.1",
"fs": "0.0.2",
"gulp": "^3.8.11",
"gulp-bower": "0.0.10",
"gulp-bump": "^0.3.0",
"gulp-concat": "^2.5.2",
"gulp-jade": "~1.0.1",
"gulp-jshint": "^1.9.2",
"gulp-merge": "^0.1.0",
"gulp-minify-css": "^1.0.0",
"gulp-minify-html": "^1.0.1",
"gulp-ng-annotate": "^0.5.2",
"gulp-ng-html2js": "^0.2.0",
"gulp-notify": "~2.2.0",
"gulp-rename": "^1.2.0",
"gulp-replace": "^0.5.3",
"gulp-sass": "^2.1.1",
"gulp-token-replace": "^1.0.2",
"gulp-uglify": "^1.1.0",
"gulp-usemin": "0.3.12",
"gulp-util": "^3.0.4",
"gulp-webserver": "~0.9.1",
"http-proxy-middleware": "0.0.5",
"jshint-stylish": "^1.0.1",
"node-constants": "^0.0.2",
"node-sass": "^3.4.2",
"path": "^0.12.7",
"require-dir": "^0.3.0",
"run-sequence": "^1.0.1",
"xmldom": "^0.1.19",
"xpath.js": "^1.0.5"
  }
}

我从这里尝试了很多事情:Can't get Gulp to run: cannot find module 'gulp-util' 没有帮助。 尝试删除node_modules,然后安装npm。重新安装bower和gulp,安装单独的gulp-util。

0 个答案:

没有答案