Tag: gruntjs

在Grunt任务中的节点JS – child_process spawn('npm install')导致ENOENT错误

我正在创作一个Grunt任务。 我试图执行npm install,然后是bower安装,然后是一个咕hub中心目标(触发多个子项目的构build命令)。 我遇到的问题与child_process谎言。 我得到产卵ENOENT错误,如果我在我的grunt任务中运行以下命令,使用当前注释掉的npm install spawn命令: var path = require('path'), projectPath = path.resolve(process.cwd(), this.data.activity ); grunt.log.debug('project path computed as: ', projectPath); process.chdir( projectPath ); console.log('current dir is: ', process.cwd()); console.log('EVN is: ', process.env); var spawnProcess = spawn('ls'); // var spawnProcess = spawn('npm install'); spawnProcess.stdout.on('data', function (data) { console.log('' + data); }); spawnProcess.stderr.on('data', function(data) { […]

gruntjs vs yeoman vs后卫

我目前正在使用警卫观看我的.coffee和.scss文件的变化,并适当地编译它们。 现在,gruntjs和yeoman提供了类似的function。 从警戒转移到gruntjs或yeoman的动机是什么? 使用yeoman vs gruntjs有什么好处,反之亦然? 谢谢!

yeomanangular发电机不会开始咕噜发球

当我与yeoman设置angular度发生器时,我做了咕噜服务后得到这个错误 module.js:340 throw err; ^ Error: Cannot find module './lexer' at Function.Module._resolveFilename (module.js:338:15) at Function.Module._load (module.js:280:25) at Module.require (module.js:364:17) at require (module.js:380:17) at Object.<anonymous> (/var/www/angMaps/node_modules/grunt/node_modules/coffee-script/lib/coffee-script/coffee-script.js:10:10) at Object.<anonymous> (/var/www/angMaps/node_modules/grunt/node_modules/coffee-script/lib/coffee-script/coffee-script.js:167:4) at Module._compile (module.js:456:26) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12)

ReferenceError:无法findvariables:require at

我有一个关于使用Grunt的茉莉花的问题。 我不断收到错误, ReferenceError:无法findvariables:require at 每当我运行我的茉莉花testing。 这是我的Gruntfile.js的jasmine条目: jasmine: { js: { src: jsFiles, options: { specs: 'tests/*_spec.js', helpers: 'tests/helpers/*', vendor: 'vendor/*' } } }, 我可以运行一个虚拟testing没有要求就好了,但是当我在一个testing中包括一个要求,像这样,我得到要求的错误。 var testD = require('../src/events_to_actions'); describe("events_to_actions", function() { it("is dummy test", function() { expect(true).toEqual(true); }); });

PhantomJS崩溃 – 退出代码126

当我尝试在CentOS(64位)系统的工作stream程中运行phantomJS时遇到一个奇怪的问题。 这是它报告的错误: [4mRunning "qunit:all" (qunit) task[24m Testing http://localhost:8000/tests.html Running PhantomJS…[31mERROR[39m [31m>> [39m/home/jenkins/jenkins/workspace/nick_node_te/web-client/client/node_modules/grunt-contrib-qunit/node_modules/grunt-lib-phantomjs/node_modules/phantomjs/lib/phantom/bin/phantomjs: /home/jenkins/jenkins/workspace/nick_node_te/web-client/client/node_modules/grunt-contrib-qunit/node_modules/grunt-lib-phantomjs/node_modules/phantomjs/lib/phantom/bin/phantomjs: cannot execute binary file 0 [ '/home/jenkins/jenkins/workspace/nick_node_te/web-client/client/node_modules/grunt-contrib-qunit/node_modules/grunt-lib-phantomjs/node_modules/phantomjs/lib/phantom/bin/phantomjs: /home/jenkins/jenkins/workspace/nick_node_te/web-client/client/node_modules/grunt-contrib-qunit/node_modules/grunt-lib-phantomjs/node_modules/phantomjs/lib/phantom/bin/phantomjs: cannot execute binary file' ] [33mWarning: PhantomJS exited unexpectedly with exit code 126. Use –force to continue.[39m [31mAborted due to warnings.[39m 我似乎无法find这种types的崩溃的任何良好的文档。 这是通常和/或值得一个错误报告? 更新: 这些是我的文件的权限: -rwxr-x–x. 1 root root 11308856 Sep 26 12:39 phantomjs

直接从Node运行Grunt Task

如何直接从Node执行一个Grunt任务,而无需将其退出到CLI? 我有以下“POC”代码; 然而,“东西”从来没有logging。 var grunt = require('grunt'); grunt.registerTask('default', 'Log some stuff.', function() { console.log('stuff'); }); grunt.task.run('default'); // This is probably not the right command 我对Grunt来说很新,所以我可能错过了一些明显的东西。 我怀疑我用来“运行”任务的命令只是排队,而实际上并没有开始运行。 不过,我找不到手动运行的文档。

一旦grunt任务完成,如何打印出文本?

一旦Grunt任务完成,我想打印出一些信息。 看到下面的Grunt片段。 有没有办法做到这一点? 我注意到grunt.task.run()不支持callback。 这会导致我的消息在覆盖率报告输出之前被打印出来。 grunt.registerTask('coverage', 'Runs all unit tests available via Mocha and generates code coverage report', function() { grunt.task.run('env:unitTest', 'mochaTest'); grunt.log.writeln('Code coverage report was generated into "build/coverage.html"'); }); 我也想避免“黑客攻击”,例如创build一个只有打印出信息并将其添加到grunt.task.run()链任务的grunt.task.run()任务。

更新grunt dev依赖关系

我相对较新,对节点还不是很熟悉。 我有一个样板Gruntfile和package.json文件,我在我的所有项目中使用,并根据需要进行修改。 当我开始每个项目时,我想更新Dev Dependencies和package.json中的所有Grunt插件,但是我不知道如何快速简单地执行此操作。 是否可以用一个命令更新所有模块,还是必须单独执行?

Grunt + require.jsconfiguration一个简单的网站

我的网站有以下简单的结构: src js core.js main.js lib jquery-1.8.2.js require-2.1.1.js require-text.js templates 1.html 2.html index.html build 我想要所有的js + lib文件被编译成一个build / js / main.js文件和其他文件,只是要复制到生成文件夹。 如何为此任务编写grunt.jsconfiguration? 看来我应该使用grunt-contrib-require .. 第二个问题是如何将1.html和2.html(我使用require text!插件)编译成每行一行,并包含这些行以构build/ js / main.js? 这种情况下应该只有两个文件到生成文件夹 – index.html和main.js.

我如何安装grunt-cli而不会出错?

受到克里斯·科伊尔(Chris Coyier)的启发,我决定咕噜一声。 但是我遇到了很大的问题。 首先,我安装了Node。 然后我添加一个package.json文件到我的项目根目录,包括: { "name": "example-project", "version": "0.1.0", "devDependencies": { "grunt": "~0.4.1" } } 然后我运行npm install 最后,我运行了npm install -g grunt-cli 其中回来了一大堆的错误: npm http GET https://registry.npmjs.org/grunt-cli npm http 304 https://registry.npmjs.org/grunt-cli npm ERR! Error: EACCES, mkdir '/usr/local/lib/node_modules/grunt-cli' npm ERR! { [Error: EACCES, mkdir '/usr/local/lib/node_modules/grunt-cli'] npm ERR! errno: 3, npm ERR! code: 'EACCES', npm ERR! path: […]