Building Babylon.js Source requires Visual Studio

Howdy @RaananW or @sebavan

UPDATE: tried with node 20.1.0 and same general error

I forked the BJS repos and have been following the docs to get started working locally. Doing a completely fresh install (I don’t think I even have TSC installed anywhere!), I ran npm install after cloning the repo, and I got a big ol’ failure with node-gyp. It looks like it was able to locate python executable (which I do happen to have installed, lucky me) and of course Node.js and NPM were also verified ok. The failure happens because it is looking for Visual Studio - any version from 2013 or higher with the “Desktop development with C++” workload installed. Obvs, I don’t have any version of VS installed (VSCode doesn’t count lol!), but I didn’t think it was required. Did this change, and/or do the docs need to reflect this requirement? Or do I just need to be on an higher-numbered Node.js version (e.g., 18+)?

Another thing that I’m probably missing something obvious – the docs mention in multiple places and contexts a “list of recommended VSCode extensions”, but I can’t seem to find that list - is it still TBD?

node version: 17.2.0
npm version: 8.12.1
Windows 11 v22H2 (22621.1555)
pwsh 7.3.4

Error log:

Long wall of text
❯ npm install
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: '@jest/schemas@29.0.0',
npm WARN EBADENGINE   required: { node: '^14.15.0 || ^16.10.0 || >=18.0.0' },
npm WARN EBADENGINE   current: { node: 'v17.2.0', npm: '8.12.1' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: '@jest/transform@29.3.1',
npm WARN EBADENGINE   required: { node: '^14.15.0 || ^16.10.0 || >=18.0.0' },
npm WARN EBADENGINE   current: { node: 'v17.2.0', npm: '8.12.1' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: '@jest/types@29.3.1',
npm WARN EBADENGINE   required: { node: '^14.15.0 || ^16.10.0 || >=18.0.0' },
npm WARN EBADENGINE   current: { node: 'v17.2.0', npm: '8.12.1' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: 'jest-haste-map@29.3.1',
npm WARN EBADENGINE   required: { node: '^14.15.0 || ^16.10.0 || >=18.0.0' },
npm WARN EBADENGINE   current: { node: 'v17.2.0', npm: '8.12.1' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: 'jest-regex-util@29.2.0',
npm WARN EBADENGINE   required: { node: '^14.15.0 || ^16.10.0 || >=18.0.0' },
npm WARN EBADENGINE   current: { node: 'v17.2.0', npm: '8.12.1' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: 'jest-util@29.3.1',
npm WARN EBADENGINE   required: { node: '^14.15.0 || ^16.10.0 || >=18.0.0' },
npm WARN EBADENGINE   current: { node: 'v17.2.0', npm: '8.12.1' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: 'jest-worker@29.3.1',
npm WARN EBADENGINE   required: { node: '^14.15.0 || ^16.10.0 || >=18.0.0' },
npm WARN EBADENGINE   current: { node: 'v17.2.0', npm: '8.12.1' }
npm WARN EBADENGINE }
npm WARN deprecated @npmcli/move-file@2.0.1: This functionality has been moved to @npmcli/fs
npm ERR! code 1
npm ERR! path C:\Users\joshe\source\Babylon.js\node_modules\node-sass
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c node scripts/build.js
npm ERR! Binary found at C:\Users\joshe\source\Babylon.js\node_modules\node-sass\vendor\win32-x64-102\binding.node
npm ERR! Testing binary
npm ERR! Binary has a problem: Error: \\?\C:\Users\joshe\source\Babylon.js\node_modules\node-sass\vendor\win32-x64-102\binding.node is not a valid Win32 application.
npm ERR! \\?\C:\Users\joshe\source\Babylon.js\node_modules\node-sass\vendor\win32-x64-102\binding.node
npm ERR!     at Object.Module._extensions..node (node:internal/modules/cjs/loader:1179:18)
npm ERR!     at Module.load (node:internal/modules/cjs/loader:975:32)
npm ERR!     at Function.Module._load (node:internal/modules/cjs/loader:822:12)
npm ERR!     at Module.require (node:internal/modules/cjs/loader:999:19)
npm ERR!     at require (node:internal/modules/cjs/helpers:102:18)
npm ERR!     at module.exports (C:\Users\joshe\source\Babylon.js\node_modules\node-sass\lib\binding.js:19:10)
npm ERR!     at Object.<anonymous> (C:\Users\joshe\source\Babylon.js\node_modules\node-sass\lib\index.js:13:35)
npm ERR!     at Module._compile (node:internal/modules/cjs/loader:1097:14)
npm ERR!     at Object.Module._extensions..js (node:internal/modules/cjs/loader:1149:10)
npm ERR!     at Module.load (node:internal/modules/cjs/loader:975:32) {
npm ERR!   code: 'ERR_DLOPEN_FAILED'
npm ERR! }
npm ERR! Building the binary locally
npm ERR! Building: C:\Program Files\nodejs\node.exe C:\Users\joshe\source\Babylon.js\node_modules\node-gyp\bin\node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp verb cli [
npm ERR! gyp verb cli   'C:\\Program Files\\nodejs\\node.exe',
npm ERR! gyp verb cli   'C:\\Users\\joshe\\source\\Babylon.js\\node_modules\\node-gyp\\bin\\node-gyp.js',
npm ERR! gyp verb cli   'rebuild',
npm ERR! gyp verb cli   '--verbose',
npm ERR! gyp verb cli   '--libsass_ext=',
npm ERR! gyp verb cli   '--libsass_cflags=',
npm ERR! gyp verb cli   '--libsass_ldflags=',
npm ERR! gyp verb cli   '--libsass_library='
npm ERR! gyp verb cli ]
npm ERR! gyp info using node-gyp@8.4.1
npm ERR! gyp info using node@17.2.0 | win32 | x64
npm ERR! gyp verb command rebuild []
npm ERR! gyp verb command clean []
npm ERR! gyp verb clean removing "build" directory
npm ERR! gyp verb command configure []
npm ERR! gyp verb find Python Python is not set from command line or npm configuration
npm ERR! gyp verb find Python Python is not set from environment variable PYTHON
npm ERR! gyp verb find Python checking if "python3" can be used
npm ERR! gyp verb find Python - executing "python3" to get executable path
npm ERR! gyp verb find Python - "python3" is not in PATH or produced an error
npm ERR! gyp verb find Python checking if "python" can be used
npm ERR! gyp verb find Python - executing "python" to get executable path
npm ERR! gyp verb find Python - executable path is "C:\Users\joshe\AppData\Local\Programs\Python\Python310\python.exe"
npm ERR! gyp verb find Python - executing "C:\Users\joshe\AppData\Local\Programs\Python\Python310\python.exe" to get version
npm ERR! gyp verb find Python - version is "3.10.10"
npm ERR! gyp info find Python using Python version 3.10.10 found at "C:\Users\joshe\AppData\Local\Programs\Python\Python310\python.exe"
npm ERR! gyp verb get node dir no --target version specified, falling back to host node version: 17.2.0
npm ERR! gyp verb command install [ '17.2.0' ]
npm ERR! gyp verb install input version string "17.2.0"
npm ERR! gyp verb install installing version: 17.2.0
npm ERR! gyp verb install --ensure was passed, so won't reinstall if already installed
npm ERR! gyp verb install version is already installed, need to check "installVersion"
npm ERR! gyp verb got "installVersion" 9
npm ERR! gyp verb needs "installVersion" 9
npm ERR! gyp verb install version is good
npm ERR! gyp verb get node dir target node version installed: 17.2.0
npm ERR! gyp verb build dir attempting to create "build" dir: C:\Users\joshe\source\Babylon.js\node_modules\node-sass\build
npm ERR! gyp verb build dir "build" dir needed to be created? Yes
npm ERR! gyp verb find VS msvs_version not set from command line or npm config
npm ERR! gyp verb find VS VCINSTALLDIR not set, not running in VS Command Prompt
npm ERR! gyp verb find VS could not use PowerShell to find Visual Studio 2017 or newer, try re-running with '--loglevel silly' for more details
npm ERR! gyp verb find VS looking for Visual Studio 2015
npm ERR! gyp verb find VS - not found
npm ERR! gyp verb find VS not looking for VS2013 as it is only supported up to Node.js 8
npm ERR! gyp ERR! find VS
npm ERR! gyp ERR! find VS msvs_version not set from command line or npm config
npm ERR! gyp ERR! find VS VCINSTALLDIR not set, not running in VS Command Prompt
npm ERR! gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer, try re-running with '--loglevel silly' for more details
npm ERR! gyp ERR! find VS looking for Visual Studio 2015
npm ERR! gyp ERR! find VS - not found
npm ERR! gyp ERR! find VS not looking for VS2013 as it is only supported up to Node.js 8
npm ERR! gyp ERR! find VS
npm ERR! gyp ERR! find VS **************************************************************
npm ERR! gyp ERR! find VS You need to install the latest version of Visual Studio
npm ERR! gyp ERR! find VS including the "Desktop development with C++" workload.
npm ERR! gyp ERR! find VS For more information consult the documentation at:
npm ERR! gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
npm ERR! gyp ERR! find VS **************************************************************
npm ERR! gyp ERR! find VS
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: Could not find any Visual Studio installation to use
npm ERR! gyp ERR! stack     at VisualStudioFinder.fail (C:\Users\joshe\source\Babylon.js\node_modules\node-gyp\lib\find-visualstudio.js:122:47)
npm ERR! gyp ERR! stack     at C:\Users\joshe\source\Babylon.js\node_modules\node-gyp\lib\find-visualstudio.js:75:16
npm ERR! gyp ERR! stack     at VisualStudioFinder.findVisualStudio2013 (C:\Users\joshe\source\Babylon.js\node_modules\node-gyp\lib\find-visualstudio.js:363:14)
npm ERR! gyp ERR! stack     at C:\Users\joshe\source\Babylon.js\node_modules\node-gyp\lib\find-visualstudio.js:71:14
npm ERR! gyp ERR! stack     at C:\Users\joshe\source\Babylon.js\node_modules\node-gyp\lib\find-visualstudio.js:384:16
npm ERR! gyp ERR! stack     at C:\Users\joshe\source\Babylon.js\node_modules\node-gyp\lib\util.js:54:7
npm ERR! gyp ERR! stack     at C:\Users\joshe\source\Babylon.js\node_modules\node-gyp\lib\util.js:33:16
npm ERR! gyp ERR! stack     at ChildProcess.exithandler (node:child_process:404:5)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:390:28)
npm ERR! gyp ERR! stack     at maybeClose (node:internal/child_process:1062:16)
npm ERR! gyp ERR! System Windows_NT 10.0.22621
npm ERR! gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\joshe\\source\\Babylon.js\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
npm ERR! gyp ERR! cwd C:\Users\joshe\source\Babylon.js\node_modules\node-sass
npm ERR! gyp ERR! node -v v17.2.0
npm ERR! gyp ERR! node-gyp -v v8.4.1
npm ERR! gyp ERR! not ok
npm ERR! Build failed with error code: 1

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\joshe\AppData\Local\npm-cache\_logs\2023-05-06T16_22_57_333Z-debug-0.log

Its because they are using node sass instead of sass. You have to rebuild cpp node addons if there isnt a prebuilt already available. So yes, u need a cpp compiler. Ms build tools or vs ide with desktop cpp workload is fine

So, dependencies failed to install?

Most projects that require binaries have binaries for lts versions of node. There is usually an issue with the latest stable lts of node until we update the dependencies.
Try node 18, it should work.
About the vscode extensions - when you use vscode it will prompt you to install the recommended extensions. Going to the extensions section of vscode will show you the list as all

1 Like

I really don’t like node-sass - sass is much better. You can switch node versions and don’t need specific binaries. That should probably be a github issue?

1 Like

I’m with you on this one. I’ll see next week if i can get rid of this dependency.

2 Likes

U can , replaced it locally many times. Idk if new repo layout has gulp sass still, but if so, replace that with gulp-dart-sass.

Gulp is long gone. I’ll check next week

2 Likes

Thanks for the tip, I’ll try node 18 tomorrow! I was working from the CLI so hadn’t looked at the VSCode extensions list yet :man_facepalming:

@jeremy-coleman - indeed, the dependency compile is why it was looking for the c++ components, my question revolves around whether/why that should be needed in the first place! :slightly_smiling_face:

@RaananW - looks like you were right about the node version. I switched to the LTS (18.16) and the dependencies installed without a hitch!

Thanks!

1 Like

i am working on updating the dependencies to support node 20 without an issue. will keep you all updated here

1 Like

[Build] Update dependencies, move to sass away from node-sass by RaananW · Pull Request #13825 · BabylonJS/Babylon.js (github.com)

3 Likes