npm install
followed by gulp build
, then proceed with the deploy.shipit development deploy
.Everything thing above works. What I'm trying to do is create a gulp deploy
task that will initialize Shipit directly, instead of using the CLI. Looks something like this:
gulp.task('shipit:deploy', function() {
var deployToEnv = argv['deploy-to'] || false;
var shipit;
return inquirer.prompt([{
type: 'list',
name: 'deployToEnv',
default: deployToEnv,
message: 'Deploy to environment:',
choices: envs
}]).then(function(answers) {
deployToEnv = answers.deployToEnv;
shipit = new Shipit({environment: deployToEnv});
shipit.initialize();
shipit.start('deploy');
});
});
Corresponding shipit config:
shipit.initConfig(config);
shipit.blTask('build', function() {
return shipit.local('npm install --silent', {
cwd: shipit.config.workspace
}).then(function() {
return shipit.local('gulp build', {
cwd: shipit.config.workspace
});
});
});
shipit.on('fetched', function() {
shipit.start('build');
});
Things appear to work with one problem: it doesn't actually perform the npm install
!
Running "npm install --silent" on local.
Running "gulp build" on local.
So, it would seem something in the npm install
command is prematurely resolving the promise, but I'm not sure how or why.
I had a similar problem (just using shipit cli) with npm warnings, which is when I discovered using the --silent arg solved that.
As a test, I left the code as is, but replaced npm install --silent
with sleep 10
. Sure enough, it waited for 10 seconds before executing gulp build
. So, it would seem it is something specific with the npm install
command.
Any help is appreciated!
shipit.local
uses child_process.exec
. I tried converting this to use child_process.spawn
, but had the same result.
If I change the command to sudo npm install
, things work as expected! So...what does this mean, and how can I avoid running it with sudo
?
Still unable to do this without sudo, but I tried adding the --verbose
flag with these results:
Without sudo
:
@ npm info it worked if it ends with ok
@ npm verb cli [ '/Users/timkelty/.nvm/versions/node/v0.12.0/bin/node',
@ npm verb cli '/Users/timkelty/.nvm/versions/node/v0.12.0/bin/npm',
@ npm verb cli 'install',
@ npm verb cli '--verbose' ]
@ npm info using [email protected]
@ npm info using [email protected]
@ npm verb install where, deps [ '/Users/timkelty/tmp/edwards-garment-website', [] ]
@ npm verb install where, peers [ '/Users/timkelty/tmp/edwards-garment-website', [] ]
@ npm info preinstall [email protected]
@ npm info build /Users/timkelty/tmp/edwards-garment-website
@ npm verb linkStuff [ false, false, false, '/Users/timkelty/tmp' ]
@ npm info linkStuff [email protected]
@ npm verb linkBins [email protected]
@ npm verb linkMans [email protected]
@ npm verb rebuildBundles [email protected]
@ npm info install [email protected]
@ npm info postinstall [email protected]
@ npm verb exit [ 0, true ]
@ npm info ok
Running "gulp build" on local.
@ [15:14:32] Local gulp not found in ~/tmp/edwards-garment-website
@ [15:14:32] Try running: npm install gulp
'build' errored after 755 ms
Error: Command failed: /bin/sh -c gulp build
With sudo
:
Running "sudo npm install --verbose" on local.
@ npm info it worked if it ends with ok
@ npm verb cli [ '/Users/timkelty/.nvm/versions/node/v0.12.0/bin/node',
@ npm verb cli '/Users/timkelty/.nvm/versions/node/v0.12.0/bin/npm',
@ npm verb cli 'install',
@ npm verb cli '--verbose' ]
@ npm info using [email protected]
@ npm info using [email protected]
@ npm verb install where, deps [ '/Users/timkelty/tmp/edwards-garment-website',
@ npm verb install [ 'Select2',
@ npm verb install 'autoprefixer-core',
@ npm verb install 'babel',
...so for some reason, when running without sudo, the npm install command seems to think it doesn't have any dependencies to install, so it finishes without error and continues to my next task.
I found the solution!
The problem was that I was trying to install devDependencies
, but when I ran the gulp deploy
command, NODE_ENV was set to production, which does not install devDependencies.
Therefore, changing the command to NODE_ENV=development npm install
seems to fix it!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With