我是Gulp的新手,正在使用tutorial。我进入最后一步,在我的项目文件中运行gulp,但是我收到一个错误,说找不到模块'gulp‘。我已经确认我已经安装了gulp。两个CLI (顺便说一句,CLI是什么意思?)本地版本为3.9.1。我想知道我做错了什么?
gulpfile.js:
// Include gulp
var gulp = require('gulp');
// Include Our Plugins
var jshint = require('gulp-jshint');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
// Lint Task
gulp.task('lint', function() {
return gulp.src('js/*.js')
.pipe(jshint())
.pipe(jshint.reporter('default'));
});
// Concatenate & Minify JS
gulp.task('scripts', function() {
return gulp.src('js/*.js')
.pipe(concat('all.js'))
.pipe(gulp.dest('dist'))
.pipe(rename('all.min.js'))
.pipe(uglify())
.pipe(gulp.dest('dist/js'));
});
// Watch Files For Changes
gulp.task('watch', function() {
gulp.watch('js/*.js', ['lint', 'scripts']);
});
// Default Task
gulp.task('default', ['lint', 'scripts', 'watch']);package.json:
{
"name": "gulp",
"version": "3.9.1",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"devDependencies": {
"gulp-concat": "^2.6.0",
"gulp-jshint": "^2.0.1",
"gulp-rename": "^1.2.2",
"gulp-uglify": "^1.5.4",
"jshint": "^2.9.2"
}
}文件结构:
|-- gulpfile.js
|-- package.json
|-- node_modules
| |-- .bin
| |-- gulp-concat
| |-- gulp-jshint
| |-- gulp-rename
| |-- gulp-uglify
| |-- jshint错误:

发布于 2016-06-24 13:26:15
问题是因为我的项目文件夹被命名为“gulp”。将项目文件夹更改为除“gulp”之外的任何其他文件夹都解决了问题。https://github.com/npm/npm/issues/11772
发布于 2016-06-24 22:23:32
在devDependencies中安装Gulp
npm install --save-dev gulp转到您的DIrectory,即
D:\xampp\htdocs\test\gulp>npm install --save-dev gulp然后按Enter键
https://stackoverflow.com/questions/38005732
复制相似问题