Я использую grunt для подготовки пакета, который я хочу развернуть, но у меня возникают проблемы при создании node_modules только для зависимостей prod.
У меня такое ощущение, что я иду по неправильному пути для этого и ищу какое-то руководство, пожалуйста.
Я попытался использовать модуль: grunt-package-modules, но я все еще получаю devзависимостей. Я попытался вызвать 'npm --only = prod install' из команды, но выдает ошибку: Ошибка: spawn npm ENOENT
module.exports = function(grunt) {
//Configure these for your project
var buildDir = "build";
var outputZip = "application.zip";
//stage the build files
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-package-modules');
grunt.loadNpmTasks('grunt-zip');
grunt.loadNpmTasks('grunt-run');
// Project configuration.
grunt.initConfig({
jshint: {
options: {
curly: false, //if true, does not allow 1 line if/else block statements without curly braces
eqnull: true, //supress == null warnings
node: true, //specify nodejs
/* use strict options */
undef: true, //prohibit the use of explicity undeclared variables
/* stylistic */
sub: true, //suppress dot notation warnings e.g. using person['name'] instead of person.name
eqeqeq: false, //allow == and != operators, do not require !== and ===
laxbreak: true,
globals: { },
},
uses_defaults: [ 'src/*.js' ], //run JSHint on all our JS files in /lib
},
packageModules: {
dist: {
src: 'package.json',
dest: buildDir
}},
clean: {
options: {
trace: true
},
init: {
src: [outputZip, buildDir]
},
cleanup:{
src: buildDir
}
},
copy:{
main: {
files:[
{
expand: true,
src: ['*.js'],
cwd: 'src',
dest: buildDir
},
{
expand: true,
src: ['node.exe'],
dest: buildDir
},
{
expand: true,
src: ['applications/**'],
dest: buildDir
},
{
expand: true,
src: ['package.json'],
dest: buildDir
}
]
}
},
run: {
npmInstall: {
cmd: 'npm',
args: [
'--only=prod',
'install',
buildDir
]
}
},
zip: {
main: {
src: buildDir + '/**',
dest: outputZip
}
}
});
grunt.registerTask('default', [
'jshint', // validate developer code with JSHint
'clean:init', // cleanup old .zip and build folder
'copy', // copy source to build folder
'run:npmInstall', // npm install
'zip', // zip it
'clean:cleanup' // remove the build folder
]);
};
/ build / node_modules содержит зависимости dev или ошибку при непосредственном вызове npm.