问题描述
这里是我的GruntFile.js
var path = require('path');
module.exports = function(grunt){
grunt.initConfig({
pkg:grunt.file.readJSON('package.json'),
uglify :{
options:{
banner:'/ *!<%= pkg.name%><%= grunt.template.today(yyyy-mm-dd)%> * / \\\
'
}
},
express:{
server:{
options:{
debug:true,
服务器:path.resolve('app.js')
}
}
},
env:{
选项:{
}
dev:{
NODE_ENV:'development'
},
prod:{
NODE_ENV:'production'
}
} ,
mochaTest:{
test:{
options:{
reporter:'spec'
},
src:['tests / *。js ']
}
}
});
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-express');
grunt.loadNpmTasks('grunt-env');
grunt.loadNpmTasks('grunt-mocha-test');
grunt.loadNpmTasks('grunt-shell');
// tasks
grunt.registerTask('start',['env:dev','express','express-keepalive']);
grunt.registerTask('stop',['express-stop']);
grunt.registerTask('test','mochaTest');
};
我使用
但是我需要将--harmony标志添加到节点可执行文件。
我该怎么做?
您需要安装 grunt-cli
本地与 npm安装grunt-cli
。 npm将把grunt二进制文件放在 ./ node_modules / .bin / grunt
。
其中:节点--harmony ./node_modules/.bin/grunt start
。
将该命令放入您的 package.json
脚本:
{
scripts {
start:node --harmony ./node_modules/.bin/grunt start
}
}
然后只需输入 npm start
。
I'm using grunt-express to do local development.
here is my GruntFile.js
var path = require('path');
module.exports = function(grunt){
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
uglify:{
options:{
banner:'/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
}
},
express:{
server:{
options:{
debug:true,
server: path.resolve('app.js')
}
}
},
env : {
options:{
},
dev : {
NODE_ENV : 'development'
},
prod : {
NODE_ENV : 'production'
}
},
mochaTest:{
test:{
options:{
reporter:'spec'
},
src:['tests/*.js']
}
}
});
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-express');
grunt.loadNpmTasks('grunt-env');
grunt.loadNpmTasks('grunt-mocha-test');
grunt.loadNpmTasks('grunt-shell');
// tasks
grunt.registerTask('start', ['env:dev', 'express', 'express-keepalive']);
grunt.registerTask('stop', ['express-stop']);
grunt.registerTask('test', 'mochaTest');
};
I start my local server with
but I need to add the --harmony flag to node executable.
How would I do this?
You would need to install grunt-cli
locally with npm install grunt-cli
. npm will put the grunt binary at ./node_modules/.bin/grunt
.
With that you can run grunt with: node --harmony ./node_modules/.bin/grunt start
.
Place that command into your package.json
scripts:
{
"scripts": {
"start": "node --harmony ./node_modules/.bin/grunt start"
}
}
and then just type npm start
.
这篇关于如何添加--harmony节点标志来进行grunt-express的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!