Express Install on my host

Hey all – first time going through the express install on a cloud vm. Always used a local docker-compose solution thus far.

I’ve installed OZ on my Ubuntu cloud host and have Ziti Controller/Ziti ER running. I have the env sourced.
ubuntu@ip-172-31-0-105:~$ echo $ZITI_HOME
/home/ubuntu/.ziti/quickstart/ip-172-31-0-105

Now installing ZAC on Controller on step 4 and I get the following error:
ubuntu@ip-172-31-0-105:~$ createZacSystemdFile
createZacSystemdFile: command not found

Ok…so that doesn’t work…move on and start ZAC manually with the following:

node "${ZITI_HOME}/ziti-console/server.js"

and get this error?

import express from 'express';
           ^^^^^^^

SyntaxError: Unexpected identifier
    at Module._compile (internal/modules/cjs/loader.js:723:23)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)

Strange that neither will work although I would prefer the systemd to function.

Can you re-run:

source /dev/stdin <<< "$(wget -qO- https://raw.githubusercontent.com/openziti/ziti/release-next/quickstart/docker/image/ziti-cli-functions.sh)";

And the try? If that doesn't work, please let us know. I just ran it myself on my AWS ubuntu image and it works. I'm thinking you might have logged out and logged back in? The helper functions are not part of the .env file that gets generated expressInstall. Only a few functions are provided (like zitiLogin).

You probably just need to source ziti-cli-functions.sh again AND the env sourced. Then you'll have createZacSystemdFile

Yep…that worked…thanks Clint

The Systemd service seems to be bouncing from activating to running continuously – found this in the logs:

Jun 28 13:20:32 ip-172-31-0-105 systemd[1]: ziti-console.service: Main process exited, code=exited, status=1/FAILURE
Jun 28 13:20:32 ip-172-31-0-105 systemd[1]: ziti-console.service: Failed with result ‘exit-code’.
Jun 28 13:20:34 ip-172-31-0-105 systemd[1]: ziti-console.service: Scheduled restart job, restart counter is at 192.
Jun 28 13:20:34 ip-172-31-0-105 systemd[1]: Stopped Ziti-Console.
Jun 28 13:20:34 ip-172-31-0-105 systemd[1]: Started Ziti-Console.
Jun 28 13:20:35 ip-172-31-0-105 node[40590]: /home/ubuntu/.ziti/quickstart/ip-172-31-0-105/ziti-console/server.js:1
Jun 28 13:20:35 ip-172-31-0-105 node[40590]: import express from ‘express’;
Jun 28 13:20:35 ip-172-31-0-105 node[40590]: ^^^^^^^
Jun 28 13:20:35 ip-172-31-0-105 node[40590]: SyntaxError: Unexpected identifier
Jun 28 13:20:35 ip-172-31-0-105 node[40590]: at Module._compile (internal/modules/cjs/loader.js:723:23)
Jun 28 13:20:35 ip-172-31-0-105 node[40590]: at Object.Module._extensions…js (internal/modules/cjs/loader.js:789:10)
Jun 28 13:20:35 ip-172-31-0-105 node[40590]: at Module.load (internal/modules/cjs/loader.js:653:32)
Jun 28 13:20:35 ip-172-31-0-105 node[40590]: at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
Jun 28 13:20:35 ip-172-31-0-105 node[40590]: at Function.Module._load (internal/modules/cjs/loader.js:585:3)
Jun 28 13:20:35 ip-172-31-0-105 node[40590]: at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
Jun 28 13:20:35 ip-172-31-0-105 node[40590]: at startup (internal/bootstrap/node.js:283:19)
Jun 28 13:20:35 ip-172-31-0-105 node[40590]: at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)

I would guess you didn’t run npm install properly.

stop the service, then run:

sudo apt install npm nodejs -y

and then run

npm install

make sure that succeeds. then run

node "${ZITI_HOME}/ziti-console/server.js"

does that final command run?

Ok…this is what I got back on that:

ubuntu@ip-172-31-0-105:~$ npm install
npm WARN saveError ENOENT: no such file or directory, open ‘/home/ubuntu/package.json’
npm WARN enoent ENOENT: no such file or directory, open ‘/home/ubuntu/package.json’
npm WARN ubuntu No description
npm WARN ubuntu No repository field.
npm WARN ubuntu No README data
npm WARN ubuntu No license field.

deleted the lock file and tried again:

ubuntu@ip-172-31-0-105:~$ npm install
npm WARN saveError ENOENT: no such file or directory, open ‘/home/ubuntu/package.json’
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open ‘/home/ubuntu/package.json’

WARN is fine. you didn’t run

node "${ZITI_HOME}/ziti-console/server.js"

?

Also you’re running

ubuntu@ip-172-31-0-105:~$ npm install

but you’re not in the ziti-console folder

Ok…ran it from the ziti-console directory and got a bit more logging…same output when running server.js tho

I’d suggest you delete the ziti-console folder, reclone and try again and follow the steps exactly :slight_smile: . There’s something goofy going on I think!?

Can you please cd to $ZITI_HOME/ziti-console and run “node server.js” and provide all the output here, formatted inside a code block.

Thanks

I ran npm install and get these errors…not sure how to fix them.

ubuntu@ip-172-31-0-105:~/.ziti/quickstart/ip-172-31-0-105/ziti-console$ npm install

> @openziti/ziti-sdk-nodejs@0.9.2 install /home/ubuntu/.ziti/quickstart/ip-172-31-0-105/ziti-console/node_modules/@openziti/ziti-sdk-nodejs
> node-pre-gyp install --fallback-to-build

node-pre-gyp ERR! install response status 403 Forbidden on https://ziti-npm.s3.amazonaws.com/ziti_sdk_nodejs/v0.9.2/Release/ziti_sdk_nodejs-v0.9.2-node-v64-linux-x64.tar.gz
node-pre-gyp WARN Pre-built binaries not installable for @openziti/ziti-sdk-nodejs@0.9.2 and node@10.19.0 (node-v64 ABI, glibc) (falling back to source compile with node-gyp)
node-pre-gyp WARN Hit error response status 403 Forbidden on https://ziti-npm.s3.amazonaws.com/ziti_sdk_nodejs/v0.9.2/Release/ziti_sdk_nodejs-v0.9.2-node-v64-linux-x64.tar.gz
make: Entering directory '/home/ubuntu/.ziti/quickstart/ip-172-31-0-105/ziti-console/node_modules/@openziti/ziti-sdk-nodejs/build'
  CC(target) Release/obj.target/ziti_sdk_nodejs/src/ziti-add-on.o
In file included from ../src/ziti-add-on.c:17:
../src/ziti-nodejs.h:23:10: fatal error: uv_mbed/uv_mbed.h: No such file or directory
   23 | #include <uv_mbed/uv_mbed.h>
      |          ^~~~~~~~~~~~~~~~~~~
compilation terminated.
make: *** [ziti_sdk_nodejs.target.mk:144: Release/obj.target/ziti_sdk_nodejs/src/ziti-add-on.o] Error 1
make: Leaving directory '/home/ubuntu/.ziti/quickstart/ip-172-31-0-105/ziti-console/node_modules/@openziti/ziti-sdk-nodejs/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/share/nodejs/node-gyp/lib/build.js:194:23)
gyp ERR! stack     at ChildProcess.emit (events.js:198:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)
gyp ERR! System Linux 5.13.0-1029-aws
gyp ERR! command "/usr/bin/node" "/usr/bin/node-gyp" "build" "--fallback-to-build" "--module=/home/ubuntu/.ziti/quickstart/ip-172-31-0-105/ziti-console/node_modules/@openziti/ziti-sdk-nodejs/build/Release/node-v64-linux-x64/ziti_sdk_nodejs.node" "--module_name=ziti_sdk_nodejs" "--module_path=/home/ubuntu/.ziti/quickstart/ip-172-31-0-105/ziti-console/node_modules/@openziti/ziti-sdk-nodejs/build/Release/node-v64-linux-x64" "--napi_version=5" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v64"
gyp ERR! cwd /home/ubuntu/.ziti/quickstart/ip-172-31-0-105/ziti-console/node_modules/@openziti/ziti-sdk-nodejs
gyp ERR! node -v v10.19.0
gyp ERR! node-gyp -v v6.1.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/usr/bin/node /usr/bin/node-gyp build --fallback-to-build --module=/home/ubuntu/.ziti/quickstart/ip-172-31-0-105/ziti-console/node_modules/@openziti/ziti-sdk-nodejs/build/Release/node-v64-linux-x64/ziti_sdk_nodejs.node --module_name=ziti_sdk_nodejs --module_path=/home/ubuntu/.ziti/quickstart/ip-172-31-0-105/ziti-console/node_modules/@openziti/ziti-sdk-nodejs/build/Release/node-v64-linux-x64 --napi_version=5 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v64' (1)
node-pre-gyp ERR! stack     at ChildProcess.cmd.on (/home/ubuntu/.ziti/quickstart/ip-172-31-0-105/ziti-console/node_modules/@mapbox/node-pre-gyp/lib/util/compile.js:89:23)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:198:13)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:982:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
node-pre-gyp ERR! System Linux 5.13.0-1029-aws
node-pre-gyp ERR! command "/usr/bin/node" "/home/ubuntu/.ziti/quickstart/ip-172-31-0-105/ziti-console/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /home/ubuntu/.ziti/quickstart/ip-172-31-0-105/ziti-console/node_modules/@openziti/ziti-sdk-nodejs
node-pre-gyp ERR! node -v v10.19.0
node-pre-gyp ERR! node-pre-gyp -v v1.0.9
node-pre-gyp ERR! not ok
Failed to execute '/usr/bin/node /usr/bin/node-gyp build --fallback-to-build --module=/home/ubuntu/.ziti/quickstart/ip-172-31-0-105/ziti-console/node_modules/@openziti/ziti-sdk-nodejs/build/Release/node-v64-linux-x64/ziti_sdk_nodejs.node --module_name=ziti_sdk_nodejs --module_path=/home/ubuntu/.ziti/quickstart/ip-172-31-0-105/ziti-console/node_modules/@openziti/ziti-sdk-nodejs/build/Release/node-v64-linux-x64 --napi_version=5 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v64' (1)
npm WARN io.netfoundry.zac@0.4.1 No repository field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @openziti/ziti-sdk-nodejs@0.9.2 (node_modules/@openziti/ziti-sdk-nodejs):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @openziti/ziti-sdk-nodejs@0.9.2 install: `node-pre-gyp install --fallback-to-build`
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1

audited 490 packages in 6.391s

28 packages are looking for funding
  run `npm fund` for details

found 3 vulnerabilities (1 low, 1 moderate, 1 high)
  run `npm audit fix` to fix them, or `npm audit` for details

Looks like @jeremy.tellier pushed an update that fixes this. could you try npm install again?

1 Like

If you still have troubles, make sure you are running node v16.15.1+. The easiest thing for that is to install nvm and let it install it for you. This guide was helpful: https://heynode.com/tutorial/install-nodejs-locally-nvm/

1 Like