我工作的项目是用gulp构建的.
最近我将节点版本更新到v6.3.1.然后出了点问题.
名为"html"的任务会引发错误.这是它的错误代码的一部分.
bogon:toClient work$ gulp html
(node:2519) fs: re-evaluating native module sources is not supported. If you are using the graceful-fs module, please update it to a more recent version.
[10:26:10] Using gulpfile ~/Project/TIME_Cancer_Treatment_Centers_of_America(CTCA)/toClient/gulpfile.js
[10:26:10] Starting 'html'...
(node:2519) fs: re-evaluating native module sources is not supported. If you are using the graceful-fs module, please update it to a more recent version.
events.js:160
throw er; // Unhandled 'error' event
^
Error: CSS parse error scripts/vendor.js: Unexpected input
1 |!function(t,e){"object"==typeof module&&"object"==typeof …Run Code Online (Sandbox Code Playgroud) 我gulp-load-plugins在TypeScript中找不到任何示例.不幸的是,我的TypeScript太难以理解,应该从@type/gulp-load-plugins
注释中做些什么.
我试过了:
import * as _gulpPlugins from 'gulp-load-plugins';
const gulpPlugins: IGulpPlugins = _gulpPlugins();
return gulp.src(sourceFilesGlobSelections)
.pipe(gulpPlugins.pug())
// ...
Run Code Online (Sandbox Code Playgroud)
它从Webpack发出4个警告(我不明白这样的数字在哪里75:13-25引用; .pipe(gulpPlugins.pug())是50行):
WARNING in ../node_modules/gulp-load-plugins/index.js 75:13-25
Critical dependency: the request of a dependency is an expression
@ ./TaskManagers/MarkupPreprocessingHelper.ts
WARNING in ../node_modules/gulp-load-plugins/index.js 81:48-63
Critical dependency: the request of a dependency is an expression
@ ./TaskManagers/MarkupPreprocessingHelper.ts
WARNING in ../node_modules/gulp-load-plugins/index.js 117:40-55
Critical dependency: the request of a dependency is an expression
@ ./TaskManagers/MarkupPreprocessingHelper.ts
WARNING in ../node_modules/gulp-load-plugins/index.js 122:51-66
Critical …Run Code Online (Sandbox Code Playgroud) Gulpfile.js
通过安装 npm install --save-dev gulp-load-plugins
var gulp = require('gulp');
// Require all tasks in gulp/tasks, including subfolders
require('require-dir')('./gulp/tasks', {
recurse: true
});
var $ = require('gulp-load-plugins')();
console.log($);
Run Code Online (Sandbox Code Playgroud)
无论我在哪里声明它,输出总是{}.我甚至试过更长版本的选项,仍然没有运气
使用$.gulpif()
给出
TypeError: Object #<Object> has no method 'gulpif'
Run Code Online (Sandbox Code Playgroud)
我甚至从github下载了一些初学者包,但仍然得到相同的输出.我正在踢自己从Grunt搬家.
gulp-load-plugins没有加载任何插件.任何人都可以建议为什么会这样?
Node: v0.12.0
NPM: v2.7.3
Run Code Online (Sandbox Code Playgroud)
我的package.json:
{
"name": "foo",
"version": "0.0.1",
"dependencies": {},
"devDependencies": {
"gulp": "^3.8.11",
"gulp-load-plugins": "^0.9.0"
}
}
Run Code Online (Sandbox Code Playgroud)
我的gulpfile.js:
var gulp = require('gulp');
var gulpLoadPlugins = require('gulp-load-plugins');
var plugins = gulpLoadPlugins();
console.log(JSON.stringify(plugins)); // {}
gulp.task('default');
Run Code Online (Sandbox Code Playgroud) 我正处于我的Gulp使用的一个阶段,它开始有意义地将任务分解为单独的文件.
为此,我希望使用gulp-load-plugins,但是虽然我的任务运行,但浏览器同步似乎不会触发/执行任何操作.
这是我的剥离设置.不知道我哪里错了!
gulpfile.js
var gulp = require('gulp'),
plugins = require('gulp-load-plugins')();
function getTask(task) {
return require('./gulp/tasks/' + task)(gulp, plugins);
}
gulp.task('browser-sync', getTask('browser-sync'));
gulp.task('bs-reload', getTask('bs-reload'));
gulp.task('scripts', getTask('scripts'));
gulp.task('default', ['browser-sync'], function(){
gulp.watch('src/js/**/*.js', ['scripts']);
});
Run Code Online (Sandbox Code Playgroud)
scripts.js(Gulp任务)
var browserSync = require('browser-sync').create();
module.exports = function(gulp, plugins) {
return function() {
return gulp.src([
'src/js/plugins/**',
'src/js/app.js',
'!src/js/{libraries,libraries/**}'
])
.pipe(plugins.plumber({
errorHandler: function(error) {
console.log(error.message);
this.emit('end');
}}))
.pipe(plugins.concat('app.js'))
.pipe(gulp.dest('dist/js/'))
.pipe(plugins.rename({
suffix: '.min'
}))
.pipe(plugins.uglify({
preserveComments: 'none'
//preserveComments: 'some'
}))
.pipe(gulp.dest('dist/js/')) // Seems okay up until here...
.pipe(browserSync.reload({ …Run Code Online (Sandbox Code Playgroud) gulp ×5
javascript ×2
node.js ×2
browser-sync ×1
node-modules ×1
npm ×1
typescript ×1
webpack ×1