Cannot Initialize New Project w/ Next.js & nextjs-styleguide
Describe the Bug
It is currently impossible to initialize and start a new JSS project on a Macbook with an Apple Silicon chip, using Next.js and the nextjs-styleguide boilerplate.
To Reproduce
-
Initialize a fresh project with the current settings. Everything was left default, except for selecting the
nextjs-styleguideaddon initializer in the last step: -
cd nextjsto navigate into the project directory -
npm run startto start the project
This results in:
> [email protected] start
> cross-env NODE_ENV=development JSS_MODE=disconnected "npm-run-all --serial bootstrap --parallel next:dev start:disconnected-proxy start:watch-components"
node:events:497
throw er; // Unhandled 'error' event
^
Error: spawn npm-run-all --serial bootstrap --parallel next:dev start:disconnected-proxy start:watch-components ENOENT
at ChildProcess._handle.onexit (node:internal/child_process:286:19)
at onErrorNT (node:internal/child_process:484:16)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
Emitted 'error' event on ChildProcess instance at:
at ChildProcess._handle.onexit (node:internal/child_process:292:12)
at onErrorNT (node:internal/child_process:484:16)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
errno: -2,
code: 'ENOENT',
syscall: 'spawn npm-run-all --serial bootstrap --parallel next:dev start:disconnected-proxy start:watch-components',
path: 'npm-run-all --serial bootstrap --parallel next:dev start:disconnected-proxy start:watch-components',
spawnargs: []
}
Node.js v20.14.0
Expected Behavior
Given this is a fresh installation, the app should run without erroring/crashing.
Possible Fix
No response
Provide environment information
- Sitecore Version: None (attempting to run in disconnected mode for now)
- JSS Version: 22.0.0 (latest)
- Browser Name and version: Mac Terminal
- Operating System and version (desktop or mobile): Mac OS 14.5 (latest) on a 14" MacBook Pro w/ M3 Pro chip
@bstaruk
Thank you for the report. We saw some issues with config formattign causing build issues on Macs. They should be fixed via https://github.com/Sitecore/jss/pull/1791 and included in the next upcoming release.
You can apply it ( extra .trim() in scripts/generate-config) right now however, the fix is app-level only.
I am running into the same issue even after applying the fix with adding the .trim(). Is there any update on this?
Hi @bnmn1895, what version of jss are you using? The fix for this issue is part of v22.1.0.
I tried following the docs so I guess it still was v21.x.
I see the same problem with JSS 22.2.1 on my MacBook Pro with a M1 chip. Replacing cross-env with cross-env-shell in the package.json file makes things start up.
hey @larserhardsen thanks for providing the workaround. we need to include some proper testing for mac os users, so I've added a topic for our team to discuss.