我正在与Grunt尝试读取特定于环境的JSON文件。但是它总是从default.json文件读取。我想念什么吗?
这是我的代码片段 Gruntfile.js
var config = require('config');
var host = config.get('host');
console.log(host);
这是我的 package.json
{
"name": "grunt",
"version": "1.0.0",
"description": "Test app",
"main": "grunt.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Me,
"devDependencies": {
"grunt": "~0.4.5",
"grunt-contrib-jshint": "~0.10.0",
"grunt-contrib-nodeunit": "~0.4.1",
"grunt-contrib-uglify": "~0.5.0",
"load-grunt-config": "^0.17.2",
"load-grunt-tasks": "^3.2.0"
}
}
我有
host=localhost
在default.json
和
host=someURL
在 production.json
我在命令行中运行的命令
$ set NODE_ENV="production"
$ grunt
localhost
Warning: Task "default" not found. Use --force to continue.
Aborted due to warnings.
我成功了 我正在使用SET
而不是export
用于设置NODE_ENV
。
$ export NODE_ENV=production
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句