openziti / ziti-sdk-nodejs

An SDK for embedding zero trust into Node.JS applications and web servers to improve security.
Apache License 2.0
72 stars 3 forks source link

npm i ziti-sdk-nodejs #28

Closed EvanGertis closed 3 years ago

EvanGertis commented 3 years ago

I am trying to install the node sdk. The goal of this project is to create a secure connection to a nodejs application. My repository for the sample application is located here.

Problem: The issue that I am currently facing is installing the sdk. When I run the command npm i ziti-sdk-nodejs. I get the following error:

npm ERR! node-pre-gyp info it worked if it ends with ok
npm ERR! node-pre-gyp info using node-pre-gyp@1.0.5
npm ERR! node-pre-gyp info using node@16.11.0 | darwin | x64
npm ERR! node-pre-gyp info check checked for "/Users/evangertis/myapp/node_modules/ziti-sdk-nodejs/build/Release/node-v93-darwin-x64/ziti_sdk_nodejs.node" (not found)
npm ERR! node-pre-gyp http GET https://ziti-npm.s3.amazonaws.com/ziti_sdk_nodejs/v0.2.7/Release/ziti_sdk_nodejs-v0.2.7-node-v93-darwin-x64.tar.gz
npm ERR! node-pre-gyp ERR! install response status 403 Forbidden on https://ziti-npm.s3.amazonaws.com/ziti_sdk_nodejs/v0.2.7/Release/ziti_sdk_nodejs-v0.2.7-node-v93-darwin-x64.tar.gz 
npm ERR! node-pre-gyp WARN Pre-built binaries not installable for ziti-sdk-nodejs@0.2.7 and node@16.11.0 (node-v93 ABI, unknown) (falling back to source compile with node-gyp) 
npm ERR! node-pre-gyp WARN Hit error response status 403 Forbidden on https://ziti-npm.s3.amazonaws.com/ziti_sdk_nodejs/v0.2.7/Release/ziti_sdk_nodejs-v0.2.7-node-v93-darwin-x64.tar.gz 
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@8.2.0
npm ERR! gyp info using node@16.11.0 | darwin | x64
npm ERR! gyp info ok 
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@8.2.0
npm ERR! gyp info using node@16.11.0 | darwin | x64
npm ERR! gyp info find Python using Python version 3.9.5 found at "/usr/local/opt/python@3.9/bin/python3.9"
npm ERR! gyp info spawn /usr/local/opt/python@3.9/bin/python3.9
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   '/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args   'binding.gyp',
npm ERR! gyp info spawn args   '-f',
npm ERR! gyp info spawn args   'make',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/Users/evangertis/myapp/node_modules/ziti-sdk-nodejs/build/config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/Users/evangertis/Library/Caches/node-gyp/16.11.0/include/node/common.gypi',
npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
npm ERR! gyp info spawn args   '-Dvisibility=default',
npm ERR! gyp info spawn args   '-Dnode_root_dir=/Users/evangertis/Library/Caches/node-gyp/16.11.0',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=/Users/evangertis/Library/Caches/node-gyp/16.11.0/<(target_arch)/node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=/Users/evangertis/myapp/node_modules/ziti-sdk-nodejs',
npm ERR! gyp info spawn args   '-Dnode_engine=v8',
npm ERR! gyp info spawn args   '--depth=.',
npm ERR! gyp info spawn args   '--no-parallel',
npm ERR! gyp info spawn args   '--generator-output',
npm ERR! gyp info spawn args   'build',
npm ERR! gyp info spawn args   '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp: Undefined variable BUILD_DATE in binding.gyp while trying to load binding.gyp
npm ERR! gyp ERR! configure error 
npm ERR! gyp ERR! stack Error: `gyp` failed with exit code: 1
npm ERR! gyp ERR! stack     at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:353:16)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:390:28)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
npm ERR! gyp ERR! System Darwin 19.6.0
npm ERR! gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/Users/evangertis/myapp/node_modules/ziti-sdk-nodejs/build/Release/node-v93-darwin-x64/ziti_sdk_nodejs.node" "--module_name=ziti_sdk_nodejs" "--module_path=/Users/evangertis/myapp/node_modules/ziti-sdk-nodejs/build/Release/node-v93-darwin-x64" "--napi_version=8" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v93"
npm ERR! gyp ERR! cwd /Users/evangertis/myapp/node_modules/ziti-sdk-nodejs
npm ERR! gyp ERR! node -v v16.11.0
npm ERR! gyp ERR! node-gyp -v v8.2.0
npm ERR! gyp ERR! not ok 
npm ERR! node-pre-gyp ERR! build error 
npm ERR! node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/Users/evangertis/myapp/node_modules/ziti-sdk-nodejs/build/Release/node-v93-darwin-x64/ziti_sdk_nodejs.node --module_name=ziti_sdk_nodejs --module_path=/Users/evangertis/myapp/node_modules/ziti-sdk-nodejs/build/Release/node-v93-darwin-x64 --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v93' (1)
npm ERR! node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/Users/evangertis/myapp/node_modules/@mapbox/node-pre-gyp/lib/util/compile.js:89:23)
npm ERR! node-pre-gyp ERR! stack     at ChildProcess.emit (node:events:390:28)
npm ERR! node-pre-gyp ERR! stack     at maybeClose (node:internal/child_process:1064:16)
npm ERR! node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)
npm ERR! node-pre-gyp ERR! System Darwin 19.6.0
npm ERR! node-pre-gyp ERR! command "/usr/local/bin/node" "/Users/evangertis/myapp/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
npm ERR! node-pre-gyp ERR! cwd /Users/evangertis/myapp/node_modules/ziti-sdk-nodejs
npm ERR! node-pre-gyp ERR! node -v v16.11.0
npm ERR! node-pre-gyp ERR! node-pre-gyp -v v1.0.5
npm ERR! node-pre-gyp ERR! not ok

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/evangertis/.npm/_logs/2021-10-08T20_13_06_500Z-debug.log

I've tried the following:

  1. npm update
  2. Running the commands:
    /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/Users/evangertis/myapp/node_modules/ziti-sdk-nodejs/build/Release/node-v93-darwin-x64/ziti_sdk_nodejs.node" "--module_name=ziti_sdk_nodejs" "--module_path=/Users/evangertis/myapp/node_modules/ziti-sdk-nodejs/build/Release/node-v93-darwin-x64" "--napi_version=8" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v93
/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/Users/evangertis/myapp/node_modules/ziti-sdk-nodejs/build/Release/node-v93-darwin-x64/ziti_sdk_nodejs.node --module_name=ziti_sdk_nodejs --module_path=/Users/evangertis/myapp/node_modules/ziti-sdk-nodejs/build/Release/node-v93-darwin-x64 --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v93

Both executed successfully independent of the install.

  1. I created a binding.gyp file
  2. 1  {                                                                                                                                                                                                                                         
    2   "targets": [
    3     {
    4       "target_name": "binding",
    5       "sources": [ "src/binding.cc" ]
    6     }
    7   ]
    8 }

I'd appreciate any advice on next steps to move forward.

Thanks, Evan

rentallect commented 3 years ago

@EvanGertis it looks like you're using Node v16.x. We do not support that version yet. Please try installing Node v14.x (via nvm, for example), and try again.

EvanGertis commented 3 years ago

@rentallect that worked thank you.

rentallect commented 3 years ago

OK, great.

The README states that "The ziti-sdk-nodejs module works with Node.js v11.x, v12.x, v13.x, v14.x". I will soon add support for newer version of Node, and update the README accordingly.

Closing this issue now.