Installing @Forge/cli is bringing spawn ts-node ENOENT error

I followed this tutorial https://developer.atlassian.com/platform/forge/getting-started/#install-the-forge-cli.

I’m on a Mac so I went through those steps: https://developer.atlassian.com/platform/forge/installing-forge-on-macos/ successfully.

When I install forge Globally:
npm install -g @forge/cli

I get this error:

events.js:291
      throw er; // Unhandled 'error' event
      ^

Error: spawn ts-node ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:268:19)
    at onErrorNT (internal/child_process.js:470:16)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)
Emitted 'error' event on ChildProcess instance at:
    at Process.ChildProcess._handle.onexit (internal/child_process.js:274:12)
    at onErrorNT (internal/child_process.js:470:16)
    at processTicksAndRejections (internal/process/task_queues.js:84:21) {
  errno: 'ENOENT',
  code: 'ENOENT',
  syscall: 'spawn ts-node',
  path: 'ts-node',
  spawnargs: [
    '/Users/soud/.nvm/versions/node/v12.22.6/lib/node_modules/@forge/cli/out/workers/forge-cli-workers.ts',
    '{"name":"@forge/cli","checkForUpdate":true,"environment":"prod"}'
  ]
}

And here are the logs:

20381 verbose lifecycle @forge/cli@2.0.2~postinstall: unsafe-perm in lifecycle true
20382 verbose lifecycle @forge/cli@2.0.2~postinstall: PATH: /Users/soud/.nvm/versions/node/v12.22.6/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/soud/.nvm/versions/node/v12.22.6/lib/node_modules/@forge/cli/node_modules/.bin:/Users/soud/.nvm/versions/node/v12.22.6/lib/node_modules/.bin:/Users/soud/.nvm/versions/node/v12.22.6/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/soud/.fig/bin
20383 verbose lifecycle @forge/cli@2.0.2~postinstall: CWD: /Users/soud/.nvm/versions/node/v12.22.6/lib/node_modules/@forge/cli
20384 silly lifecycle @forge/cli@2.0.2~postinstall: Args: [
20384 silly lifecycle   '-c',
20384 silly lifecycle   `node -e "process.exitCode = fs.existsSync('./out/bin/postinstall.js')" || node ./out/bin/postinstall.js`
20384 silly lifecycle ]
20385 silly lifecycle @forge/cli@2.0.2~postinstall: Returned: code: 1  signal: null
20386 info lifecycle @forge/cli@2.0.2~postinstall: Failed to exec postinstall script
20387 timing action:postinstall Completed in 1146ms
20388 verbose unlock done using /Users/soud/.npm/_locks/staging-6b08d295ad269dee.lock for /Users/soud/.nvm/versions/node/v12.22.6/lib/node_modules/.staging
20389 timing stage:rollbackFailedOptional Completed in 1945ms
20390 timing stage:runTopLevelLifecycles Completed in 18387ms
20391 verbose stack Error: @forge/cli@2.0.2 postinstall: `node -e "process.exitCode = fs.existsSync('./out/bin/postinstall.js')" || node ./out/bin/postinstall.js`
20391 verbose stack Exit status 1
20391 verbose stack     at EventEmitter.<anonymous> (/Users/soud/.nvm/versions/node/v12.22.6/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
20391 verbose stack     at EventEmitter.emit (events.js:314:20)
20391 verbose stack     at ChildProcess.<anonymous> (/Users/soud/.nvm/versions/node/v12.22.6/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
20391 verbose stack     at ChildProcess.emit (events.js:314:20)
20391 verbose stack     at maybeClose (internal/child_process.js:1022:16)
20391 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:287:5)
20391 verbose stack From previous event:
20391 verbose stack     at runAction (/Users/soud/.nvm/versions/node/v12.22.6/lib/node_modules/npm/lib/install/actions.js:74:13)
20391 verbose stack     at actions.<computed> (/Users/soud/.nvm/versions/node/v12.22.6/lib/node_modules/npm/lib/install/actions.js:50:17)
20391 verbose stack     at execAction (/Users/soud/.nvm/versions/node/v12.22.6/lib/node_modules/npm/lib/install/actions.js:191:18)
20391 verbose stack From previous event:
20391 verbose stack     at /Users/soud/.nvm/versions/node/v12.22.6/lib/node_modules/npm/lib/install/actions.js:159:15
20391 verbose stack From previous event:
20391 verbose stack     at withInit (/Users/soud/.nvm/versions/node/v12.22.6/lib/node_modules/npm/lib/install/actions.js:175:13)
20391 verbose stack     at runSerial (/Users/soud/.nvm/versions/node/v12.22.6/lib/node_modules/npm/lib/install/actions.js:158:10)
20391 verbose stack     at doSerial (/Users/soud/.nvm/versions/node/v12.22.6/lib/node_modules/npm/lib/install/actions.js:139:3)
20391 verbose stack     at Array.<anonymous> (/Users/soud/.nvm/versions/node/v12.22.6/lib/node_modules/npm/node_modules/slide/lib/bind-actor.js:15:8)
20391 verbose stack     at LOOP (/Users/soud/.nvm/versions/node/v12.22.6/lib/node_modules/npm/node_modules/slide/lib/chain.js:15:14)
20391 verbose stack     at /Users/soud/.nvm/versions/node/v12.22.6/lib/node_modules/npm/node_modules/slide/lib/chain.js:18:7
20391 verbose stack     at /Users/soud/.nvm/versions/node/v12.22.6/lib/node_modules/npm/lib/install/actions.js:163:5
20391 verbose stack     at processImmediate (internal/timers.js:461:21)
20392 verbose pkgid @forge/cli@2.0.2
20393 verbose cwd /Users/soud/code/Axolo/jira
20394 verbose Darwin 20.6.0
20395 verbose argv "/Users/soud/.nvm/versions/node/v12.22.6/bin/node" "/Users/soud/.nvm/versions/node/v12.22.6/bin/npm" "install" "-g" "@forge/cli"
20396 verbose node v12.22.6
20397 verbose npm  v6.14.15
20398 error code ELIFECYCLE
20399 error errno 1
20400 error @forge/cli@2.0.2 postinstall: `node -e "process.exitCode = fs.existsSync('./out/bin/postinstall.js')" || node ./out/bin/postinstall.js`
20400 error Exit status 1
20401 error Failed at the @forge/cli@2.0.2 postinstall script.
20401 error This is probably not a problem with npm. There is likely additional logging output above.
20402 verbose exit [ 1, true ]

Their seems to be an error with the postinstall script but didn’t manage to find out where it came from ! Any help would be greatly appreciated.

I’ve seen a similar error and the solution was to install and use lts/erbium, which I did but the same error appears

Hi @SydneyCohen, looking at the error and at our postinstall script, it seems like you may have NODE_ENV=development set in your shell environment.

Perhaps you had set it earlier in the same terminal session, or maybe it’s set in your bashrc or bash_profile?

To confirm whether this is the issue, you could unset the NODE_ENV in your terminal session before running npm install -g @forge/cli by running unset NODE_ENV.

1 Like

@kchan That did the trick thank you !