hanazuki / node-jsonnet

libjsonnet binding for Node.js
https://www.npmjs.com/package/@hanazuki/node-jsonnet
MIT License
33 stars 1 forks source link

Install fails on Windows/MSVC #63

Open iatzmon opened 3 years ago

iatzmon commented 3 years ago

Running npm install in an empty project yields the following output:

C:\dev\jsonnet-test>npm install @hanazuki/node-jsonnet

> @hanazuki/node-jsonnet@0.4.2 install C:\dev\jsonnet-test\node_modules\@hanazuki\node-jsonnet
> cmake-js build --CDCMAKE_EXPORT_COMPILE_COMMANDS=1

[
  'C:\\Program Files\\nodejs\\node.exe',
  'C:\\dev\\jsonnet-test\\node_modules\\cmake-js\\bin\\cmake-js',
  'build',
  '--CDCMAKE_EXPORT_COMPILE_COMMANDS=1'
]
info TOOL Using Visual Studio 16 2019 generator.
info CMD CONFIGURE
info RUN [
info RUN   'cmake',
info RUN   'C:\\dev\\jsonnet-test\\node_modules\\@hanazuki\\node-jsonnet',
info RUN   '--no-warn-unused-cli',
info RUN   '-G',
info RUN   'Visual Studio 16 2019',
info RUN   '-A',
info RUN   'x64',
info RUN   '-DCMAKE_JS_VERSION=6.2.1',
info RUN   '-DCMAKE_BUILD_TYPE=Release',
info RUN   '-DCMAKE_RUNTIME_OUTPUT_DIRECTORY=C:\\dev\\jsonnet-test\\node_modules\\@hanazuki\\node-jsonnet\\build',
info RUN   '-DCMAKE_JS_INC=<REDACTED>\\.cmake-js\\node-x64\\v14.17.0\\include\\node',
info RUN   '-DCMAKE_JS_SRC=C:/dev/jsonnet-test/node_modules/cmake-js/lib/cpp/win_delay_load_hook.cc',
info RUN   '-DNODE_RUNTIME=node',
info RUN   '-DNODE_RUNTIMEVERSION=14.17.0',
info RUN   '-DNODE_ARCH=x64',
info RUN   '-DCMAKE_JS_LIB=<REDACTED>\\.cmake-js\\node-x64\\v14.17.0\\win-x64\\node.lib',
info RUN   '-DCMAKE_EXPORT_COMPILE_COMMANDS=1',
info RUN   '-DCMAKE_SHARED_LINKER_FLAGS=/DELAYLOAD:NODE.EXE'
info RUN ]
Not searching for unused variables given on the command line.
-- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19042.
-- The C compiler identification is MSVC 19.29.30040.0
-- The CXX compiler identification is MSVC 19.29.30040.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.29.30037/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.29.30037/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Deprecation Warning at third_party/jsonnet/CMakeLists.txt:2 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.

CMake Error at third_party/jsonnet/CMakeLists.txt:43 (message):
  Compiler MSVC not supported

-- Configuring incomplete, errors occurred!
See also "C:/dev/jsonnet-test/node_modules/@hanazuki/node-jsonnet/build/CMakeFiles/CMakeOutput.log".
ERR! OMG Process terminated: 1
npm WARN @hanazuki/node-jsonnet@0.4.2 requires a peer of @types/node@* but none is installed. You must install peer dependencies yourself.
npm WARN jsonnet-test@1.0.0 No description
npm WARN jsonnet-test@1.0.0 No repository field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @hanazuki/node-jsonnet@0.4.2 install: `cmake-js build --CDCMAKE_EXPORT_COMPILE_COMMANDS=1`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @hanazuki/node-jsonnet@0.4.2 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!     <REDACTED>\AppData\Roaming\npm-cache\_logs\2021-08-10T14_14_02_481Z-debug.log
hanazuki commented 3 years ago

Thanks for your report. This library currently does not support Windows build as our dependency libjsonnet does not so. They have an open issue for Windows support that you might help resolve: https://github.com/google/jsonnet/issues/734

hanazuki commented 3 years ago

That error comes from this line https://github.com/google/jsonnet/blob/108e5d7ba7de3dfa42468461acbb3b1385aed629/CMakeLists.txt#L42 and I think the expected fix is only to set up the compiler-specific command line options for MSVC.

hanazuki commented 3 years ago

Started some trial and error at #65. It would be appreciated if you could help debug it :)

iatzmon commented 3 years ago

Thanks for the quick response, much appreciated!

The build succeeds now when installing the package but when I try to use it I get the following error:

Error: The specified module could not be found.
\\?\C:\Users\itama\dev\jsonnet-test\node_modules\@hanazuki\node-jsonnet\build\Release\node-jsonnet.node
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:1131:18)
    at Module.load (internal/modules/cjs/loader.js:937:32)
    at Function.Module._load (internal/modules/cjs/loader.js:778:12)
    at Module.require (internal/modules/cjs/loader.js:961:19)
    at require (internal/modules/cjs/helpers.js:92:18)
    at bindings (C:\Users\itama\dev\jsonnet-test\node_modules\bindings\bindings.js:112:48)
    at Object.<anonymous> (C:\Users\itama\dev\jsonnet-test\node_modules\@hanazuki\node-jsonnet\lib\index.js:2:36)
    at Module._compile (internal/modules/cjs/loader.js:1072:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
    at Module.load (internal/modules/cjs/loader.js:937:32)

The node-jsonnet.node file does exist in the module's folder

I uploaded my test repo to https://github.com/Osherg/jsonnet-test