3

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\NormalModuleFactory.js:205:8)
2017-09-13T20:06:17.9961416Z     at _combinedTickCallback (internal/process/next_tick.js:67:7)
2017-09-13T20:06:17.9961416Z     at process._tickCallback (internal/process/next_tick.js:98:9)
2017-09-13T20:06:17.9961416Z 13 09 2017 15:06:13.823: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\NormalModuleFactory.js:205:8)
2017-09-13T20:06:17.9961416Z     at _combinedTickCallback (internal/process/next_tick.js:67:7)
2017-09-13T20:06:17.9961416Z     at process._tickCallback (internal/process/next_tick.js:98:9)

The two scrips that are running are:

"test": "SET NODE_ENV=test&& karma start karma.conf.js"

and

"build:prod:aot": "rimraf aot && ngc -p ./tsconfig-aot.json && SET NODE_ENV=production&& webpack"

The error is coming from karma. I get the same error from vNext no matter how I try to run these two scripts. I have tried

  • Adding a script to run them with the concurrently npm package. Executed using a Windows batch command.
  • Adding a script to run them with the npm-run-all npm package. Executed using a Windows batch command.
  • Running a powershell .ps1 script to run each command with Start-Job.
  • Running a .bat file that in turn runs two other .bat files, one for each script.

In every case I get the exact same error from vNext. In every case I get the expected result when running from my laptop, a VM, and when running the script while logged into the build server.

What am I missing here? Why is vNext behaving differently?

7
  • I assume your build are not run through a CMD call directly but by a direct system call, as such the SET command is no op and doesn't populate the environment variable for the next chained command. Prepend them with cmd /c and you should be OK.
    – Tensibai
    Sep 14, 2017 at 14:20
  • I'm trying to understand what you mean,but it's not making sense to me. I setup the build to run my scripts with a Command Line task and a PowerShell task. Both end up giving me the same result.
    – Aaron
    Sep 14, 2017 at 15:03
  • That's an assumption, I may be wrong but the error looks like it's searching for a profile valued by environment variable NODE_ENV which is filled by Set which works in console but not within the build system. I'm not using TFS so it's just a guess
    – Tensibai
    Sep 14, 2017 at 15:17
  • If SET doesn't work in the build environment, then that would explain why I can remote into the build server and run the script and it succeeds. I'm going to try a different approach using a Run Script task to execute a .bat file. The Run Script task has an option to allow it to modify the environment.
    – Aaron
    Sep 14, 2017 at 15:28
  • Well, that didn't work. Still getting the same error.
    – Aaron
    Sep 14, 2017 at 16:08

1 Answer 1

1

The conflict is occurring between 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"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.