Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to start service after upgrade to z2m 1.21 #4

Open
DatCFC opened this issue Aug 3, 2021 · 9 comments
Open

Unable to start service after upgrade to z2m 1.21 #4

DatCFC opened this issue Aug 3, 2021 · 9 comments

Comments

@DatCFC
Copy link

DatCFC commented Aug 3, 2021

Hi @paxswill , I followed the upgrade procedure to get version 1.21, which is the latest release version as of 08/03/21:

  1. stop
  2. cd to /opt/zigbee2mqtt
  3. git pull
  4. npm ci --production
  5. start

Following this the service would not start.
I'm away from system right now. I can post log later.
Wanted to check if this was just an issue on my end or if others see the same with 1.21.

Thanks

@tebra-jl
Copy link

tebra-jl commented Aug 10, 2021

Same problem here.
This is the output when starting zigbee2mqtt

> [email protected] start /opt/zigbee2mqtt
> node index.js

Building Zigbee2MQTT... (initial build), failed
node:child_process:326
      ex = new Error('Command failed: ' + cmd + '\n' + stderr);
           ^

Error: Command failed: npm run build
sh: tsc: not found
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! [email protected] build: `tsc && node index.js writehash`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the [email protected] 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!     /root/.npm/_logs/2021-08-10T18_17_06_822Z-debug.log

    at ChildProcess.exithandler (node:child_process:326:12)
    at ChildProcess.emit (node:events:369:20)
    at maybeClose (node:internal/child_process:1067:16)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5) {
  killed: false,
  code: 1,
  signal: null,
  cmd: 'npm run build'
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `node index.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start 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!     /root/.npm/_logs/2021-08-10T18_17_06_903Z-debug.log

And this is the /root/.npm/_logs/2021-08-10T18_17_06_903Z-debug.log

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'start' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle [email protected]~prestart: [email protected]
6 info lifecycle [email protected]~start: [email protected]
7 verbose lifecycle [email protected]~start: unsafe-perm in lifecycle true
8 verbose lifecycle [email protected]~start: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/opt/zigbee2mqtt/node_modules/.bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/root/bin
9 verbose lifecycle [email protected]~start: CWD: /opt/zigbee2mqtt
10 silly lifecycle [email protected]~start: Args: [ '-c', 'node index.js' ]
11 silly lifecycle [email protected]~start: Returned: code: 1  signal: null
12 info lifecycle [email protected]~start: Failed to exec start script
13 verbose stack Error: [email protected] start: `node index.js`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack     at EventEmitter.emit (node:events:369:20)
13 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (node:events:369:20)
13 verbose stack     at maybeClose (node:internal/child_process:1067:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)
14 verbose pkgid [email protected]
15 verbose cwd /opt/zigbee2mqtt
16 verbose FreeBSD 12.2-RELEASE-p6
17 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
18 verbose node v15.14.0
19 verbose npm  v6.14.8
20 error code ELIFECYCLE
21 error errno 1
22 error [email protected] start: `node index.js`
22 error Exit status 1
23 error Failed at the [email protected] start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

@tebra-jl
Copy link

I think I find a solution here
Koenkk/zigbee2mqtt#8222
but I don't know how to do it.

@paxswill
Copy link
Owner

@DatCFC sorry for not getting to this sooner.

z2m now has an extra step in the upgrade process, after npm ci, you need to run npm run build to compile the TypeScript files. I've recently made some updates to the rc script so you should be able to do service zigbee2mqtt upgrade (from within the jail) to get things working again (and probably service zigbee2mqtt start afterwards as it hasn't been running).

Please let me know if this solves the issue for y'all.

@tebra-jl
Copy link

Still don't run after npm run build and service zigbee2mqtt upgrade
This is the log

Building Zigbee2MQTT... (initial build), failed
node:child_process:326
      ex = new Error('Command failed: ' + cmd + '\n' + stderr);
           ^

Error: Command failed: npm run build
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! [email protected] build: `tsc && node index.js writehash`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

    at ChildProcess.exithandler (node:child_process:326:12)
    at ChildProcess.emit (node:events:369:20)
    at maybeClose (node:internal/child_process:1067:16)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5) {
  killed: false,
  code: 2,
  signal: null,
  cmd: 'npm run build'
}

@DatCFC
Copy link
Author

DatCFC commented Aug 10, 2021

@DatCFC sorry for not getting to this sooner.

z2m now has an extra step in the upgrade process, after npm ci, you need to run npm run build to compile the TypeScript files. I've recently made some updates to the rc script so you should be able to do service zigbee2mqtt upgrade (from within the jail) to get things working again (and probably service zigbee2mqtt start afterwards as it hasn't been running).

Please let me know if this solves the issue for y'all.

Thanks. That worked. As far as I'm concerned we can close the issue, but I see that not everyone is successful in updating it.

Still don't run after npm run build and service zigbee2mqtt upgrade
This is the log

Building Zigbee2MQTT... (initial build), failed
node:child_process:326
      ex = new Error('Command failed: ' + cmd + '\n' + stderr);
           ^

Error: Command failed: npm run build
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! [email protected] build: `tsc && node index.js writehash`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

    at ChildProcess.exithandler (node:child_process:326:12)
    at ChildProcess.emit (node:events:369:20)
    at maybeClose (node:internal/child_process:1067:16)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5) {
  killed: false,
  code: 2,
  signal: null,
  cmd: 'npm run build'
}

@tebra-jl I switched to the dev branch as Koenkk sugested on this topic: Koenkk/zigbee2mqtt#8222
Not sure if it's meant to work on the main branch yet.

@tebra-jl
Copy link

I switched to dev branch but it still don't works.
Also try a fresh build of the jail and failed with this error:

 2 warnings generated.
 sh: tsc: not found
 npm ERR!  code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
 npm ERR! [email protected] build: `tsc && node index.js writehash`
 npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the [email protected] 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!     /root/.npm/_logs/2021-08-11T09_38_39_364Z-debug.log
zigbee2mqtt-2 had a failure
Exception: SystemExit Message: 1
Partial plugin destroyed

The message sh: tsc: not found is maybe the source of the error ?

@tebra-jl
Copy link

OK I have to go back to a old snapshot with version 1.19.1
Now could you please tell me how to properly update the jail and zigbee2mqtt to last version ?

@paxswill
Copy link
Owner

paxswill commented Aug 11, 2021

Upgrading this plugin should be done from outside the jail with iocage upgrade $JAIL_NAME (with JAIL_NAME being the name of the plugin jail). That will upgrade the packages within the jail as well as this plugin's files in the jail. It'll also take a snapshot before the upgrade.

Right now it does look like the release branch of z2m is a little broken for our usage, so until there's a new release you'll have to use the dev branch (didn't catch this before as I was already on dev). To switch and upgrade to the dev branch:

# Within the jail
service zigbee2mqtt stop
cd /opt/zigbee2mqtt
git checkout HEAD -- npm-shrinkwrap.json
git fetch
git checkout dev
git pull
npm ci
npm run build
service zigbee2mqtt start

You might need to repeat the last two npm commands to get all of the dependencies installed properly. (so ci, run build, ci, run build). After this, using service zigbee2mqtt upgrade within the jail should upgrade z2m (although you'll probably want to switch back to the release branch once there's been a new release).

@adorobis
Copy link

Have the same issue when installing fresh 1.22.0 or after upgrading from 1.20.0. Errors after npm run build:

/root/.npm/_logs/2021-11-18T12_01_16_412Z-debug.log
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'run', 'build' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle [email protected]~prebuild: [email protected]
6 info lifecycle [email protected]~build: [email protected]
7 verbose lifecycle [email protected]~build: unsafe-perm in lifecycle true
8 verbose lifecycle [email protected]~build: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/opt/zigbee2mqtt/node_modules/.bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/root/bin
9 verbose lifecycle [email protected]~build: CWD: /opt/zigbee2mqtt
10 silly lifecycle [email protected]~build: Args: [ '-c', 'tsc && node index.js writehash' ]
11 silly lifecycle [email protected]~build: Returned: code: 2  signal: null
12 info lifecycle [email protected]~build: Failed to exec build script
13 verbose stack Error: [email protected] build: `tsc && node index.js writehash`
13 verbose stack Exit status 2
13 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:400:28)
13 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:400:28)
13 verbose stack     at maybeClose (internal/child_process.js:1058:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:293:5)
14 verbose pkgid [email protected]
15 verbose cwd /opt/zigbee2mqtt
16 verbose FreeBSD 12.2-RELEASE-p10
17 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "build"
18 verbose node v14.18.1
19 verbose npm  v6.14.8
20 error code ELIFECYCLE
21 error errno 2
22 error [email protected] build: `tsc && node index.js writehash`
22 error Exit status 2
23 error Failed at the [email protected] build script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 2, true ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants