patternshellMinor
Why is my build script only failing when it is run in a vNext build?
Viewed 0 times
scriptwhyvnextfailingonlywhenbuildrun
Problem
I am running a build process on an on-prem server with TFS 2017 and vNext. The build works, but it takes 20+ minutes. This is an application that does msbuild, ngc, yarn, and karma. I would be totally fine with leaving it the way it is except for the 20 minutes it takes. I found a way to reduce the build by at least 8 minutes by running two of the yarn scripts in parallel. I have been able to successfully run these two scripts in parallel on my laptop, on a VM, and directly on the build server (I remote into the server to do it). However, every attempt to make this work through vNext fails with the exact same error.
Here is the error:
```
2017-09-13T20:06:17.9961416Z 13 09 2017 15:06:13.808:ERROR [karma]: TypeError: Cannot read property 'profile' of null
2017-09-13T20:06:17.9961416Z at factoryCallback (D:\Agents\Agent1\_work\126\s\Src\BFY.Admin.Web\node_modules\webpack\lib\Compilation.js:269:13)
2017-09-13T20:06:17.9961416Z at factory (D:\Agents\Agent1\_work\126\s\Src\BFY.Admin.Web\node_modules\webpack\lib\NormalModuleFactory.js:253:5)
2017-09-13T20:06:17.9961416Z at applyPluginsAsyncWaterfall (D:\Agents\Agent1\_work\126\s\Src\BFY.Admin.Web\node_modules\webpack\lib\NormalModuleFactory.js:99:14)
2017-09-13T20:06:17.9961416Z at D:\Agents\Agent1\_work\126\s\Src\BFY.Admin.Web\node_modules\tapable\lib\Tapable.js:204:11
2017-09-13T20:06:17.9961416Z at NormalModuleFactory.params.normalModuleFactory.plugin (D:\Agents\Agent1\_work\126\s\Src\BFY.Admin.Web\node_modules\webpack\lib\CompatibilityPlugin.js:52:5)
2017-09-13T20:06:17.9961416Z at NormalModuleFactory.applyPluginsAsyncWaterfall (D:\Agents\Agent1\_work\126\s\Src\BFY.Admin.Web\node_modules\tapable\lib\Tapable.js:208:13)
2017-09-13T20:06:17.9961416Z at resolver (D:\Agents\Agent1\_work\126\s\Src\BFY.Admin.Web\node_modules\webpack\lib\NormalModuleFactory.js:74:11)
2017-09-13T20:06:17.9961416Z at process.nextTick (D:\Agents\Agent1\_work\126\s\Src\BFY.Admin.Web\node_modules\webpack\lib\Nor
Here is the error:
```
2017-09-13T20:06:17.9961416Z 13 09 2017 15:06:13.808:ERROR [karma]: TypeError: Cannot read property 'profile' of null
2017-09-13T20:06:17.9961416Z at factoryCallback (D:\Agents\Agent1\_work\126\s\Src\BFY.Admin.Web\node_modules\webpack\lib\Compilation.js:269:13)
2017-09-13T20:06:17.9961416Z at factory (D:\Agents\Agent1\_work\126\s\Src\BFY.Admin.Web\node_modules\webpack\lib\NormalModuleFactory.js:253:5)
2017-09-13T20:06:17.9961416Z at applyPluginsAsyncWaterfall (D:\Agents\Agent1\_work\126\s\Src\BFY.Admin.Web\node_modules\webpack\lib\NormalModuleFactory.js:99:14)
2017-09-13T20:06:17.9961416Z at D:\Agents\Agent1\_work\126\s\Src\BFY.Admin.Web\node_modules\tapable\lib\Tapable.js:204:11
2017-09-13T20:06:17.9961416Z at NormalModuleFactory.params.normalModuleFactory.plugin (D:\Agents\Agent1\_work\126\s\Src\BFY.Admin.Web\node_modules\webpack\lib\CompatibilityPlugin.js:52:5)
2017-09-13T20:06:17.9961416Z at NormalModuleFactory.applyPluginsAsyncWaterfall (D:\Agents\Agent1\_work\126\s\Src\BFY.Admin.Web\node_modules\tapable\lib\Tapable.js:208:13)
2017-09-13T20:06:17.9961416Z at resolver (D:\Agents\Agent1\_work\126\s\Src\BFY.Admin.Web\node_modules\webpack\lib\NormalModuleFactory.js:74:11)
2017-09-13T20:06:17.9961416Z at process.nextTick (D:\Agents\Agent1\_work\126\s\Src\BFY.Admin.Web\node_modules\webpack\lib\Nor
Solution
The conflict is occurring between
Also, running with PowerShell is not necessarily a good idea since it interprets some of the output differently than the Windows shell. For example, some packages will write out "warnings" to the error stream.
ngc and webpack. When rimraf aot && ngc -p ./tsconfig-aot.json is moved to its own script and executed prior to test and build:prod:aot then running test and build:prod:aot with npm-run-all will work as expected. Also, running with PowerShell is not necessarily a good idea since it interprets some of the output differently than the Windows shell. For example, some packages will write out "warnings" to the error stream.
"build:prod:aot": "rimraf aot && ngc -p ./tsconfig-aot.json",
"webpack:prod": "SET NODE_ENV=production&& webpack",
"test": "SET NODE_ENV=test&& karma start karma.conf.js",
"buildAndTest": "npm-run-all build:prod:aot --parallel test webpack:prod"Code Snippets
"build:prod:aot": "rimraf aot && ngc -p ./tsconfig-aot.json",
"webpack:prod": "SET NODE_ENV=production&& webpack",
"test": "SET NODE_ENV=test&& karma start karma.conf.js",
"buildAndTest": "npm-run-all build:prod:aot --parallel test webpack:prod"Context
StackExchange DevOps Q#2004, answer score: 1
Revisions (0)
No revisions yet.