$是没有定义的脚本Gulp任务
嗨,我正在尝试运行我的脚本任务吞咽。 我的脚本path定义如下:
scripts: { coffee: [ 'app/assets/scripts/**/*.coffee' ], js: [ 'src/js/*', 'src/js/**/*' ], map: ['src/js/**/*.map'] },
我的原始文件path位于root / src / js /中,我希望我的脚本放在root / app / assets / scripts /中的缩小版本中。
我的g task任务如下:
gulp.task('scripts', function() { return gulp.src('app/scripts/**/*.js') .pipe($.if('*.js', $.uglify({preserveComments: 'some'}))) .pipe($.sourcemaps.init()) .pipe($.concat('app.js')) .pipe($.sourcemaps.write('./')) .pipe(gulp.dest('app/assets/scripts')); }); But for some reason I keep getting this error [13:28:46] ReferenceError: $ is not defined at Gulp.<anonymous> (C:\Users\Myuser\apps\myapp\gulpfile.js:165:9) at module.exports (C:\Users\Myuser\apps\myapp\node_modules\gulp\node_ modules\orchestrator\lib\runTask.js:34:7) at Gulp.Orchestrator._runTask (C:\Users\Myuser\apps\myapp\node_module s\gulp\node_modules\orchestrator\index.js:273:3) at Gulp.Orchestrator._runStep (C:\Users\Myuser\apps\myapp\node_module s\gulp\node_modules\orchestrator\index.js:214:10) at Gulp.Orchestrator.start (C:\Users\Myuser\apps\myapp\node_modules\g ulp\node_modules\orchestrator\index.js:134:8) at C:\Users\Myuser\AppData\Roaming\npm\node_modules\gulp\bin\gulp.js:129:2 0 at process._tickCallback (node.js:355:11) at Function.Module.runMain (module.js:503:11) at startup (node.js:129:16) at node.js:814:3
UPDATE
嘿,我认为你是对的。 $
没有定义,应该是$ = require('gulp-load-plugins')();
。 但是现在我正在运行scripts
,出现以下错误:
[15:24:46] TypeError: undefined is not a function at Gulp.<anonymous> (C:\Users\Myuser\apps\myapp\gulpfile.js:166:13) at module.exports (C:\Users\Myuser\apps\myapp\node_modules\gulp\node_ modules\orchestrator\lib\runTask.js:34:7) at Gulp.Orchestrator._runTask (C:\Users\Myuser\apps\myapp\node_module s\gulp\node_modules\orchestrator\index.js:273:3) at Gulp.Orchestrator._runStep (C:\Users\Myuser\apps\myapp\node_module s\gulp\node_modules\orchestrator\index.js:214:10) at Gulp.Orchestrator.start (C:\Users\Myuser\apps\myapp\node_modules\g ulp\node_modules\orchestrator\index.js:134:8) at C:\Users\Myuser\AppData\Roaming\npm\node_modules\gulp\bin\gulp.js:129:2 0 at process._tickCallback (node.js:355:11) at Function.Module.runMain (module.js:503:11) at startup (node.js:129:16) at node.js:814:3
再次,另一个模糊的错误“未定义不是一个函数”,这是明确的? 有没有$
function缺失?
您可能需要使用gulp-load-plugins软件包:
var $ = require('gulp-load-plugins')({lazy: true});
- 启动Node.js服务器W / GULP“连接”rest实时刷新(Angular应用W / HTML5模式)
- 我怎样才能得到browserify的“捆绑”function发出结束事件?
- ES 2015 VS 2015 for node.js运行任务运行器资源pipe理器
- 从VS 2015 Task Runner资源pipe理器运行时,Gulp任务失败,但不是从命令提示符运行
- 在通过gulp-submodule注入依赖项的模块上运行gulp任务,通过gulp-submodule依次拥有自己的依赖项,失败
- 链接吞吐任务和传递variables
- Npm包安装失败 – 如何恢复旧的工作版本?
- NodeJS&Gulp Streams&乙烯文件对象 – 用于NPM包装的Gulp Wrapper产生不正确的输出
- 尝试运行一个例子吞噬的问题 – “inheritance`的超级构造函数不能为空或未定义。