I am trying to get a build going for Aurelia on VSO Hosted Build Controller. I created a small powershell script to run the following commands
npm install
.node_modules/.bin/jspm cc
.node_modules/.bin/jspm install -y
.node_modules/.bin/gulp build
I do have AfterBuild targets to copy the jspm_packages and dist folders to my _publishedWebsites folder.
npm install runs fine, but when it comes to jspm cc (if I remove the jspm cc and let it run jspm install -y), it fails trying to this
jspm cc
Migrating global jspm folder from C:\Users\buildguest\.jspm to C:\Users\buildguest\AppData\Local\.jspm...
Copying configuration...
err Error migrating to new jspm folder
2>EXEC : error : ENOENT, no such file or directory 'C:\Users\buildguest\.jspm\config' [d:\a\src\WebGUI\OwinAureliaScaffold\OwinAureliaScaffold.csproj]
at Object.fs.openSync (evalmachine.<anonymous>:427:18)
at Object.fs.readFileSync (evalmachine.<anonymous>:284:15)
at Object.<anonymous> (d:\a\src\WebGUI\OwinAureliaScaffold\public\node_modules\jspm\lib\global-config.js:36:24)
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)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (d:\a\src\WebGUI\OwinAureliaScaffold\public\node_modules\jspm\lib\registry.js:19:20)
ok Loader file cache cleared.
ok Package cache cleared.
I do understand the jspm is not installed globally, since it is a hosted controller, I cannot really install it globally. My question is, how do I work through this without having a global jspm install? Is there a workaround where it does not have to migrate the config file?
Even though you cannot install and run the jspm CLI on the hosted build agent, you can run jspm through node itself.
First, make sure jspm is installed - which your powershell script does. Alternatively, you can use VSO Build's "npm install task", provided jspm is in your package.json
file.
I used Gulp to execute jspm through node. I'm not sure if that's the best way to do this step, but it works... I used VSO's "Gulp task"
Here are the relevant bits from gulpfile.js
:
var gulp = require('gulp'),
exec = require('child_process').exec;
//#region Build Tasks
gulp.task('build:jspm', function (cb) {
exec("node ./node_modules/jspm/jspm.js install", function(err, stdout, stderr) {
console.log(stdout);
console.error(stderr);
cb(err);
});
});
gulp.task('_build', ['build:jspm']);
I do understand the jspm is not installed globally, since it is a hosted controller, I cannot really install it globally.
It appears that this is not true (at least currently.) You can install jspm globally on a hosted controller.
I was able to solve this with a build process that looks like this:
1) Installs all of the local dependencies from my package.json. 2) Installs a global version of JSPM 3) Evokes it from the global installation location
I realized from M Falanga's answer that node was obviously in the controller's path so I could call it from Powershell/command line. The global JSPM install location I found from looking at the build's debug logs. Note to implementors, you'll want to make sure your working directory for steps 1 and 3 are set to where your package.json is located.
Alternative Solution
I have not tested this next option in a build yet but you should be able to skip the extra build steps and just use the scripts feature of NPM to do the JSPM install. In this case you won't need the NPM install step nor the Run node step above.
In your package.json you'll need the following script entry:
"keywords": [...],
"scripts": {
"postinstall": "./node_modules/.bin/jspm install -y"
},
"jspm": {...
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