11.2 macOS - PWA localhost server fails with error code ELIFECYCLE

I’m attempting to build a PWA for our Bible with version 11.2. PWA seems to build without errors but when SAB attempts to launch the NPM Preview in Terminal it fails with the error code ELIFECYCLE

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node',
1 verbose cli   '/usr/local/bin/npm',
1 verbose cli   'run',
1 verbose cli   'preview',
1 verbose cli   '--',
1 verbose cli   '--open' ]
2 info using npm@6.11.1
3 info using node@v10.15.3
4 verbose run-script [ 'preview' ]
5 info lifecycle appbuilder-pwa@0.0.1~preview: appbuilder-pwa@0.0.1
6 verbose lifecycle appbuilder-pwa@0.0.1~preview: unsafe-perm in lifecycle true
7 verbose lifecycle appbuilder-pwa@0.0.1~preview: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/private/var/folders/pw/pdbsf3hs4k51606jxr15vxvr0000gn/T/App Builder/preview/appbuilder-pwa/node_modules/.bin:/Library/Frameworks/Python.framework/Versions/3.12/bin:/opt/local/bin:/opt/local/sbin:/Library/Frameworks/Python.framework/Versions/3.7/bin:/Library/Frameworks/Python.framework/Versions/3.7/bin:/Library/Frameworks/Python.framework/Versions/3.7/bin:/usr/local/bin:/usr/local/sbin:/Users/kane/.fastlane/bin:/usr/local/mysql/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/Applications/VMware Fusion.app/Contents/Public:/usr/local/go/bin
8 verbose lifecycle appbuilder-pwa@0.0.1~preview: CWD: /private/var/folders/pw/pdbsf3hs4k51606jxr15vxvr0000gn/T/App Builder/preview/appbuilder-pwa
9 silly lifecycle appbuilder-pwa@0.0.1~preview: Args: [ '-c', 'vite preview --host "--open"' ]
10 silly lifecycle appbuilder-pwa@0.0.1~preview: Returned: code: 1  signal: null
11 info lifecycle appbuilder-pwa@0.0.1~preview: Failed to exec preview script
12 verbose stack Error: appbuilder-pwa@0.0.1 preview: `vite preview --host "--open"`
12 verbose stack Exit status 1
12 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
12 verbose stack     at EventEmitter.emit (events.js:189:13)
12 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
12 verbose stack     at ChildProcess.emit (events.js:189:13)
12 verbose stack     at maybeClose (internal/child_process.js:970:16)
12 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
13 verbose pkgid appbuilder-pwa@0.0.1
14 verbose cwd /private/var/folders/pw/pdbsf3hs4k51606jxr15vxvr0000gn/T/App Builder/preview/appbuilder-pwa
15 verbose Darwin 23.4.0
16 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "preview" "--" "--open"
17 verbose node v10.15.3
18 verbose npm  v6.11.1
19 error code ELIFECYCLE
20 error errno 1
21 error appbuilder-pwa@0.0.1 preview: `vite preview --host "--open"`
21 error Exit status 1
22 error Failed at the appbuilder-pwa@0.0.1 preview script.
22 error This is probably not a problem with npm. There is likely additional logging output above.
23 verbose exit [ 1, true ]

I’m kind of dead in the water without being able to preview the PWA output. I tried several ELIFECYCLE error fixes off the Google, but none solved the issue.
Does anyone have any help for me here or another way to preview the output? I tried just opening the index.html page in my browser, but I just get a blank white page

Hello @bkane,

I am sorry that I missed your message. The reason it is not working is that it is using the wrong version of node. It should be using the node v20 that is included in Scripture App Builder. I see that it is somehow using node v10.

When you click on “Run PWA”, SAB generates a build folder in $TMPDIR/App\ Builder/build/SAB.XXX/p (where XXX is the numeric index of the project in the list of projects). In that folder there is a buildpwa.sh which has lines like this:

export PATH="/Applications/Scripture App Builder.app/Contents/Resources/Java/tools/node/bin":$PATH
echo ""
echo "*** NPM Version ***"
npm --version
echo ""
echo "*** NPM Install ***"
echo "Installing dependencies..."
npm install --loglevel info
echo ""
echo "*** NPM Build ***"
npm run build

If the PATH is getting setup correctly, you should see this in the output:

*** NPM Version ***
10.1.0

*** NPM Install ***
Installing dependencies...
npm info using npm@10.1.0
npm info using node@v20.9.0

You can edit the buildpwa.sh to add:

echo $PATH

after the export PATH= line and maybe we can see why it is not picking up the node in your app.

You can also verify that the node folder is there. Here are the options:

  1. In Finder, browse to the Applications folder and right-click on Scripture App Builder and select “Show Package Contents” and then navigate to Contents/Resources/Java/tools/node/bin and verify there is an entry for “npm”.
  2. Go to a terminal and run ls /Applications/Scripture\ App\ Builder.app/Contents/Resources/Java/tools/node/bin and verify there is an entry for “npm”

If it doesn’t, try downloading a fresh copy of Scripture App Builder.

Chris

So I tried as you suggested and for some reason it kept picking up /usr/local/lib/ as the first PATH directory. So after trying a few things to get the build path to be the first directory, I gave up and just updated npm on my mac to the latest. I’m not sure why I didn’t just do that at first. Anyway, the end is that it’s working now even though its still using the lib node instead of the build path node.