NPM Run Build Gives Errors

Pulling the current version of BJS locally and compiling with npm run build results in the following errors (full log follows)

.............
[09:36:54] 'buildMin' errored after 1.7 min
[09:36:54] Error in plugin "webpack-stream"
Message:
    [at-loader] ..\..\src\Engines\Extensions\engine.cubeTexture.ts:298:102
    TS2345: Argument of type 'HTMLCanvasElement | OffscreenCanvas' is not assignable to parameter of type 'TexImageSource'.
  Type 'OffscreenCanvas' is not assignable to type 'TexImageSource'.
    Type 'OffscreenCanvas' is not assignable to type 'HTMLCanvasElement'.
[at-loader] ..\..\src\Engines\Extensions\engine.videoTexture.ts:48:17
    TS2322: Type 'CanvasRenderingContext2D | WebGLRenderingContext | OffscreenCanvasRenderingContext2D' is not assignable to type 'Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>'.
  Type 'WebGLRenderingContext' is not assignable to ........

Full Log

User@User-PC MINGW64 ~/Documents/GitHub/Babylon.js/Tools/Gulp (master)
$ npm run build

> babylonjs@0.0.0 build C:\Users\User\Documents\GitHub\Babylon.js\Tools\Gulp
> gulp --max-old-space-size=8192 --tsLintFix

[09:32:32] Node flags detected: --max-old-space-size=8192
[09:32:32] Respawned to PID: 17400
[09:33:07] Using gulpfile ~\Documents\GitHub\Babylon.js\Tools\Gulp\gulpfile.js
[09:33:07] Starting 'default'...
[09:33:07] Starting 'cleanup'...
Cleaning up from 3.3
[09:33:07] Finished 'cleanup' after 25 ms
[09:33:07] Starting 'tsLint'...
[09:33:07] Starting 'typescript-libraries-tsLint'...
[09:33:07] Starting 'core-tsLint'...
[09:33:29] Finished 'core-tsLint' after 22 s
[09:33:29] Starting 'materialsLibrary-tsLint'...
[09:33:30] Finished 'materialsLibrary-tsLint' after 806 ms
[09:33:30] Starting 'postProcessesLibrary-tsLint'...
[09:33:30] Finished 'postProcessesLibrary-tsLint' after 155 ms
[09:33:30] Starting 'proceduralTexturesLibrary-tsLint'...
[09:33:30] Finished 'proceduralTexturesLibrary-tsLint' after 349 ms
[09:33:30] Starting 'loaders-tsLint'...
[09:33:31] Finished 'loaders-tsLint' after 1.06 s
[09:33:31] Starting 'serializers-tsLint'...
[09:33:32] Finished 'serializers-tsLint' after 466 ms
[09:33:32] Starting 'gui-tsLint'...
[09:33:33] Finished 'gui-tsLint' after 1.4 s
[09:33:33] Finished 'typescript-libraries-tsLint' after 26 s
[09:33:33] Finished 'tsLint' after 26 s
[09:33:33] Starting 'importLint'...
[09:33:33] Starting 'typescript-libraries-importLint'...
[09:33:33] Starting 'core-importLint'...
[09:33:33] Starting 'shaders'...
[09:33:35] Finished 'shaders' after 1.67 s
[09:33:35] Starting 'lint'...
[09:33:39] Finished 'lint' after 3.55 s
[09:33:39] Finished 'core-importLint' after 5.28 s
[09:33:39] Starting 'materialsLibrary-importLint'...
[09:33:39] Starting 'shaders'...
[09:33:39] Finished 'shaders' after 365 ms
[09:33:39] Starting 'lint'...
[09:33:39] Finished 'lint' after 273 ms
[09:33:39] Finished 'materialsLibrary-importLint' after 657 ms
[09:33:39] Starting 'postProcessesLibrary-importLint'...
[09:33:39] Starting 'shaders'...
[09:33:39] Finished 'shaders' after 53 ms
[09:33:39] Starting 'lint'...
[09:33:39] Finished 'lint' after 90 ms
[09:33:39] Finished 'postProcessesLibrary-importLint' after 152 ms
[09:33:39] Starting 'proceduralTexturesLibrary-importLint'...
[09:33:39] Starting 'shaders'...
[09:33:40] Finished 'shaders' after 135 ms
[09:33:40] Starting 'lint'...
[09:33:40] Finished 'lint' after 137 ms
[09:33:40] Finished 'proceduralTexturesLibrary-importLint' after 278 ms
[09:33:40] Starting 'loaders-importLint'...
[09:33:40] Starting 'shaders'...
[09:33:40] Finished 'shaders' after 25 ms
[09:33:40] Starting 'lint'...
[09:33:40] Finished 'lint' after 182 ms
[09:33:40] Finished 'loaders-importLint' after 231 ms
[09:33:40] Starting 'serializers-importLint'...
[09:33:40] Starting 'shaders'...
[09:33:40] Finished 'shaders' after 22 ms
[09:33:40] Starting 'lint'...
[09:33:40] Finished 'lint' after 114 ms
[09:33:40] Finished 'serializers-importLint' after 174 ms
[09:33:40] Starting 'gui-importLint'...
[09:33:40] Starting 'shaders'...
[09:33:40] Finished 'shaders' after 50 ms
[09:33:40] Starting 'lint'...
[09:33:40] Finished 'lint' after 223 ms
[09:33:40] Finished 'gui-importLint' after 279 ms
[09:33:40] Starting 'inspector-importLint'...
[09:33:40] Starting 'shaders'...
[09:33:40] Finished 'shaders' after 110 ms
[09:33:40] Starting 'lint'...
[09:33:43] Finished 'lint' after 2.02 s
[09:33:43] Finished 'inspector-importLint' after 2.14 s
[09:33:43] Starting 'nodeEditor-importLint'...
[09:33:43] Starting 'shaders'...
[09:33:43] Finished 'shaders' after 214 ms
[09:33:43] Starting 'lint'...
[09:33:46] Finished 'lint' after 2.84 s
[09:33:46] Finished 'nodeEditor-importLint' after 3.09 s
[09:33:46] Finished 'typescript-libraries-importLint' after 12 s
[09:33:46] Finished 'importLint' after 12 s
[09:33:46] Starting 'circularDependencies'...
[09:33:46] Starting 'core-circularDependencies'...
[09:34:50] No New circular dependencies.
[09:34:50] Finished 'core-circularDependencies' after 1.07 min
[09:34:50] Starting 'materialsLibrary-circularDependencies'...
[09:34:57] No New circular dependencies.
[09:34:57] Finished 'materialsLibrary-circularDependencies' after 6.55 s
[09:34:57] Starting 'postProcessesLibrary-circularDependencies'...
[09:34:58] No New circular dependencies.
[09:34:58] Finished 'postProcessesLibrary-circularDependencies' after 733 ms
[09:34:58] Starting 'proceduralTexturesLibrary-circularDependencies'...
[09:34:59] No New circular dependencies.
[09:34:59] Finished 'proceduralTexturesLibrary-circularDependencies' after 1.53 s
[09:34:59] Starting 'loaders-circularDependencies'...
[09:35:03] No New circular dependencies.
[09:35:03] Finished 'loaders-circularDependencies' after 3.62 s
[09:35:03] Starting 'serializers-circularDependencies'...
[09:35:05] No New circular dependencies.
[09:35:05] Finished 'serializers-circularDependencies' after 2.13 s
[09:35:05] Starting 'gui-circularDependencies'...
[09:35:10] No New circular dependencies.
[09:35:10] Finished 'gui-circularDependencies' after 5.41 s
[09:35:10] Finished 'circularDependencies' after 1.4 min
[09:35:10] Starting 'typescript-all'...
[09:35:10] Starting 'typescript-libraries'...
[09:35:10] Starting 'core'...
[09:35:10] Starting 'cleanup'...
[09:35:11] Finished 'cleanup' after 461 ms
[09:35:11] Starting 'shaders'...
[09:35:12] Finished 'shaders' after 933 ms
[09:35:12] Starting 'buildMin'...
i 「atl」: Using typescript@3.5.3 from typescript
i 「atl」: Using tsconfig.json from C:/Users/User/Documents/GitHub/Babylon.js/src/tsconfig.json
(node:17400) [DEP0097] DeprecationWarning: Using a domain property in MakeCallback is deprecated. Use the async_context variant of MakeCallback or the AsyncResource class instead.
i 「atl」: Checking started in a separate process...
× 「atl」: Checking finished with 8 errors
[09:36:54] 'buildMin' errored after 1.7 min
[09:36:54] Error in plugin "webpack-stream"
Message:
    [at-loader] ..\..\src\Engines\Extensions\engine.cubeTexture.ts:298:102
    TS2345: Argument of type 'HTMLCanvasElement | OffscreenCanvas' is not assignable to parameter of type 'TexImageSource'.
  Type 'OffscreenCanvas' is not assignable to type 'TexImageSource'.
    Type 'OffscreenCanvas' is not assignable to type 'HTMLCanvasElement'.
[at-loader] ..\..\src\Engines\Extensions\engine.videoTexture.ts:48:17
    TS2322: Type 'CanvasRenderingContext2D | WebGLRenderingContext | OffscreenCanvasRenderingContext2D' is not assignable to type 'Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>'.
  Type 'WebGLRenderingContext' is not assignable to type 'Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>'.
    Type 'WebGLRenderingContext' is not assignable to type 'OffscreenCanvasRenderingContext2D'.
[at-loader] ..\..\src\Engines\Extensions\engine.videoTexture.ts:55:111
    TS2345: Argument of type 'HTMLCanvasElement | OffscreenCanvas' is not assignable to parameter of type 'TexImageSource'.
  Type 'OffscreenCanvas' is not assignable to type 'TexImageSource'.
    Type 'OffscreenCanvas' is not assignable to type 'HTMLCanvasElement'.
[at-loader] ..\..\src\Engines\thinEngine.ts:918:13
    TS2322: Type 'CanvasRenderingContext2D | WebGLRenderingContext | OffscreenCanvasRenderingContext2D' is not assignable to type 'Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>'.
  Type 'WebGLRenderingContext' is not assignable to type 'Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>'.
    Type 'WebGLRenderingContext' is missing the following properties from type 'OffscreenCanvasRenderingContext2D': commit, restore, save, getTransform, and 55 more.
[at-loader] ..\..\src\Engines\thinEngine.ts:2896:107
    TS2345: Argument of type 'HTMLCanvasElement | OffscreenCanvas' is not assignable to parameter of type 'TexImageSource'.
  Type 'OffscreenCanvas' is not assignable to type 'TexImageSource'.
    Type 'OffscreenCanvas' is missing the following properties from type 'HTMLCanvasElement': requestPointerLock, isRecording, captureStream, toBlob, and 239 more.
[at-loader] ..\..\src\Engines\thinEngine.ts:4242:44
    TS2345: Argument of type '"webgl"' is not assignable to parameter of type '"2d"'.
[at-loader] ..\..\src\Meshes\Builders\groundBuilder.ts:402:21
    TS2339: Property 'drawImage' does not exist on type 'CanvasRenderingContext2D | WebGLRenderingContext | OffscreenCanvasRenderingContext2D'.
  Property 'drawImage' does not exist on type 'WebGLRenderingContext'.
[at-loader] ..\..\src\Meshes\Builders\groundBuilder.ts:406:52
    TS2339: Property 'getImageData' does not exist on type 'CanvasRenderingContext2D | WebGLRenderingContext | OffscreenCanvasRenderingContext2D'.
  Property 'getImageData' does not exist on type 'WebGLRenderingContext'.
Details:
    domainEmitter: [object Object]
    domain: [object Object]
    domainThrown: false

[09:36:54] 'core' errored after 1.72 min
[09:36:54] 'typescript-libraries' errored after 1.72 min
[09:36:54] 'typescript-all' errored after 1.72 min
[09:36:54] 'default' errored after 3.77 min
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! babylonjs@0.0.0 build: `gulp --max-old-space-size=8192 --tsLintFix`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the babylonjs@0.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\User\AppData\Roaming\npm-cache\_logs\2019-10-08T08_36_55_289Z-debug.log

I had the same error some days ago. Not sure how I fixed this, but I believe it was about the location from where I ran “npm run build”. Are you in the “Tools/Gulp” directory ? or at the root directory when executing it ?

Or maybe what I’m telling about has nothing to do with your issue …

I’d try upgrading typescript. Here it says ~3.6.3:

and you are using 3.5.3.

That changed occurred on Oct 2nd:

Definitely have TS 3.6.3 installed but log file still gives a ref to 3.5.3

[16:20:54] Starting 'buildMin'...
i 「atl」: Using typescript@3.5.3 from typescript
i 「atl」: Using tsconfig.json from C:/Users/User/Documents/GitHub/Babylon.js/src/tsconfig.json

make sure to run npm install in tools/gulp (and do that after deleting your node_modules folder at the root)

When I do this I get

User@User-PC MINGW64 ~/Documents/GitHub/Babylon.js/Tools/Gulp (master)
$ npm install

> babylonjs@0.0.0 install C:\Users\User\Documents\GitHub\Babylon.js\Tools\Gulp
> cd ../../ && npm install && cd Playground/ && npm install && cd ../Viewer && npm install && cd ../Tools/Gulp/

npm ERR! code 1
npm ERR! Command failed: git submodule update -q --init --recursive
npm ERR! C:/Program Files/Git/mingw64/libexec/git-core\git-submodule: line 19: .: git-sh-setup: file not found
npm ERR!

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\User\AppData\Roaming\npm-cache\_logs\2019-10-08T16_50_09_109Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! babylonjs@0.0.0 install: `cd ../../ && npm install && cd Playground/ && npm install && cd ../Viewer && npm install && cd ../Tools/Gulp/`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the babylonjs@0.0.0 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\User\AppData\Roaming\npm-cache\_logs\2019-10-08T16_50_09_357Z-debug.log

User@User-PC MINGW64 ~/Documents/GitHub/Babylon.js/Tools/Gulp (master)

woot! pinging @sebavan

I have never tried in MINGW64 could you try directly on windows ?

Also are you running with node 10+ ?

PS C:\Users\User\documents\github> cd babylon.js
PS C:\Users\User\documents\github\babylon.js> cd tools
PS C:\Users\User\documents\github\babylon.js\tools> cd gulp
PS C:\Users\User\documents\github\babylon.js\tools\gulp> node -v
v10.15.0
PS C:\Users\User\documents\github\babylon.js\tools\gulp> npm run build

> babylonjs@0.0.0 build C:\Users\User\documents\github\babylon.js\tools\gulp
> gulp --max-old-space-size=8192 --tsLintFix

[17:59:34] Node flags detected: --max-old-space-size=8192
[17:59:34] Respawned to PID: 1288
[17:59:36] Local gulp not found in ~\documents\github\babylon.js\tools\gulp
[17:59:36] Try running: npm install gulp
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! babylonjs@0.0.0 build: `gulp --max-old-space-size=8192 --tsLintFix`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the babylonjs@0.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\User\AppData\Roaming\npm-cache\_logs\2019-10-08T16_59_36_301Z-debug.log
PS C:\Users\User\documents\github\babylon.js\tools\gulp>

As you can see node version is 10.15.0

EDIT Just realised it says to install gulp

So using Windows power shell rather than git bash seems to have solved it.

Windows informed me to install gulp which git bash didn’t and even when I installed gulp git bash gave the same errors as before.

EDIT no I was wrong eventually these errors appeared

× 「atl」: Checking finished with 1 errors
[18:24:15] 'buildMin' errored after 2.32 min
[18:24:15] Error in plugin "webpack-stream"
Message:
    [at-loader] ..\..\src\sceneComponent.ts:213:15
    TS2343: This syntax requires an imported helper named '__spreadArrays', but module 'tslib' has no exported member '__spreadArrays'.
Details:
    domainEmitter: [object Object]
    domain: [object Object]
    domainThrown: false

[18:24:15] 'core' errored after 2.35 min
[18:24:15] 'typescript-libraries' errored after 2.35 min
[18:24:15] 'typescript-all' errored after 2.35 min
[18:24:15] 'default' errored after 6.08 min
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! babylonjs@0.0.0 build: `gulp --max-old-space-size=8192 --tsLintFix`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the babylonjs@0.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\User\AppData\Roaming\npm-cache\_logs\2019-10-08T17_24_16_375Z-debug.log
PS C:\Users\User\documents\github\babylon.js\tools\gulp>

Enough for tonight!!! Try again tomorrow.

S2343: This syntax requires an imported helper named ‘__spreadArrays’

Seems you are not on the right ts version could you install ts 3.6.3 globally then also try deleting the .temp folder in your babylon.js directory.

Let s see if that works before investigating further.

I had the same error on my computer and:

  • Deleting node_modules did not help
  • Removing .temp did not help

I have no idea why yet…

Ok thanks to @bghgary, I tried “git clean -dxf” at the root of the repo and it worked…No idea what was wrong though

git dark forces fighting against npm hell armies… no one wants to be a part of that :smiley:

1 Like