Tag: gulp

Gulp错误(找不到模块)

我根据文章在本地安装npm(我不记得URL)。 所以我的npm包在~/.npm-packages/ 。 所以~/.npm-packages/bin/gulp在~/.npm-packages/bin/gulp ,这是一个链接: gulp -> ../lib/node_modules/gulp/bin/gulp.js 当我运行which gulp我/ /家/ /home/victor/.npm-packages/bin/gulp 当我进入bin目录并运行./gulp.js -v像./gulp.js -v我可以看到它的作品。 然而,当我全球运行gulp时,我得到了这样的错误: module.js:338 throw err; ^ Error: Cannot find module '/usr/lib/node_modules/gulp/node_modules/v8flags/3.28.73.flags.json' at Function.Module._resolveFilename (module.js:336:15) at Function.Module._load (module.js:278:25) at Module.require (module.js:365:17) at require (module.js:384:17) at Object.<anonymous> (/usr/lib/node_modules/gulp/bin/gulp.js:25:22) at Module._compile (module.js:460:26) at Object.Module._extensions..js (module.js:478:10) at Module.load (module.js:355:32) at Function.Module._load (module.js:310:12) at Function.Module.runMain (module.js:501:10) […]

如何在Windows 7中运行吞咽?

我试图在Windows 7上运行gulp。我相信我有所有依赖关系,但是当我在缺省的cmd或posh-git中inputgulp时,我收到以下错误: gulp : The term 'gulp' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + gulp + ~~~~ + CategoryInfo : ObjectNotFound: (gulp:String) […]

从gulp中使用browserify时如何暴露“要求”浏览器?

当我有一个文件x.js,看起来像这样: x.js module.exports = function (n) { return n * 111 } 我从命令行运行browserify就像这样: browserify -r ./x.js > bundle.js 我得到一个看起来像这样(粗略)的输出文件: require=(function e(t,n,r){function …… ./App.jsx":[function(require,module,exports){ module.exports=require('0+DPR/'); },{}]},{},[]) 然后在我的浏览器代码中,我可以这样做: <html> <head> <title>React server rendering example</title> <script src="static/bundle.js"></script> </head> <body> Welcome to the React server rendering example. Here is a server-rendered React component: <div id="53a442ff8b39d"></div><script> var x = require('./x.js'); […]

升级到node.js 4.1后,gulp不再工作

我刚刚从节点0.12.x升级到4.1.0。 这样做后, gulp不再起作用。 我尝试运行gulp后,在控制台中看到了这些 module.js:338 throw err; ^ Error: Cannot find module '/Users/me/.node/lib/node_modules/gulp/node_modules/v8flags/cache/4.5.103.35.flags.json' at Function.Module._resolveFilename (module.js:336:15) at Function.Module._load (module.js:286:25) at Module.require (module.js:365:17) at require (module.js:384:17) at Object.<anonymous> (/Users/me/.node/lib/node_modules/gulp/bin/gulp.js:25:22) at Module._compile (module.js:434:26) at Object.Module._extensions..js (module.js:452:10) at Module.load (module.js:355:32) at Function.Module._load (module.js:310:12) at Function.Module.runMain (module.js:475:10) 我试过运行npm install ,并更新到最新版本的gulp但是没有解决问题。 有想法该怎么解决这个吗?

跳过本地安装Gulp

我可以以某种方式跳过Gulp的本地安装到项目中吗? 我在全球范围内安装了Gulp,并将其作为依赖项添加到package.json中。 但是仍然Gulp想要被安装在本地也Local gulp not found in …信息的Local gulp not found in … 。 如果我做本地安装,Gulp会被复制到我的项目中。 有没有办法跳过本地安装Gulp? 我希望能够通过命令行在整个服务器上运行它,并在全局范围内pipe理它的安装。

如何解决未处理的“错误”事件。 在使用Gulp时破坏了“A”的@import声明?

我一直在愉快地编译使用gulp.js,但今天下午我开始得到这个错误: events.js:72 throw er; // Unhandled 'error' event ^ Error: Broken @import declaration of "A" 我的gulpfile.js看起来像这样: var gulp = require('gulp'), minifyCSS = require('gulp-minify-css'), sass = require('gulp-ruby-sass'), imagemin = require('gulp-imagemin') minifyHTML = require('gulp-minify-html'), uglify = require('gulp-uglify'), fileinclude = require('gulp-file-include'); gulp.task('sass', function() { return sass('node_modules/foundation/scss/') .on('error', function (err) { console.error('Error!', err.message); }) .pipe(gulp.dest('publish/css')); }); gulp.task('image', function(){ gulp.src('images/*') […]

制作一个大文件:调用gulp.parallel时出错

我正在通读Gulp入门书(2015年1月出版),但是我意识到,因为Gulp的发展正在迅速进行,所以可能已经过时了。 这是我的gulpfile: // Modules & Plugins var gulp = require('gulp'); var concat = require('gulp-concat'); var myth = require('gulp-myth'); var uglify = require('gulp-uglify'); // newly added var jshint = require('gulp-jshint'); // newly added var imagemin = require('gulp-imagemin'); // let's add two node.js modules: var connect = require('connect'); // var serve = require('serve-static'); var browsersync = require('browser-sync'); […]

gulp-usemin可以接受多个文件吗?

我有一个usemin的问题,我不知道这是否是一个错误。 我的应用程序结构很简单: – root |- gulpfile.js |- app | |- index.html | |- about.html | |- contact.html | |- js | |- a.js | |- b.js | |- c.js | |- d.js | |- e.js | |- dist 我的每个html文件都有一个usemin块来包含所有的脚本,例如: <!– build:js js/app.js –> <script src="../js/a.js"></script> <script src="../js/b.js"></script> <script src="../js/c.js"></script> <script src="../js/d.js"></script> <script src="../js/e.js"></script> <!– endbuild […]

如何处理非SPA使用的项目级捆绑?

我正在学习browserify,我正在尝试做两件基本的事情: 转换(通过填充)非CommonJS模块,便于使用和依赖性跟踪 捆绑项目特定的库 我发现了一个如何做到这一切的工作stream程,并通过Gulp实现了自动化。 这工作,并产生正确的输出,但我很好奇,如果它可以变得更简单。 似乎我必须在基于项目的包上重复大量的configuration。 这是一个工作的例子: 的package.json 无效的评论添加澄清 { //project info and dependencies omitted //https://github.com/substack/node-browserify#browser-field "browser": { //tell browserify about some of my libraries and where they reside "jquery": "./bower_components/jquery/dist/jquery.js", "bootstrap": "./bower_components/bootstrap/dist/js/bootstrap.js" }, "browserify": { //https://github.com/substack/node-browserify#browserifytransform "transform": [ "browserify-shim" ] }, "browserify-shim": { //shim the modules defined above as needed "jquery": { "exports": "$" […]

在因子束的部分束上进行一些操作

我正在用browserify和factor-bundle来使用gulp。 我有以下代码: b = browserify({ entries: [ 'a.js', 'b.js'], plugin: [ [ 'factor-bundle', { outputs: [ 'build/a.js', 'build/b.js' ] } ] ] }) .bundle() .pipe(source('bundle.js')) .pipe(buffer()) .pipe(gulp.dest('/build/common')); 我想在这个parial bundles('build / a.js'和'build / b.js')上进行一些操作(比如uglify,bundle-collapser或其他工作)。 我尝试使用factor-bundle页面上描述的方法: b.plugin('factor-bundle', { outputs: [ write('x'), write('y') ] }); function write (name) { return concat(function (body) { console.log('// —– ' + name […]