jss
jss copied to clipboard
getMetadata() does not work when using npm workspaces
Describe the Bug
Writing component builder to /home/runner/work/aceik-sandpit-xmc/aceik-sandpit-xmc/src/rendering/apps/aceik-demo/src/temp/componentBuilder.ts
Error: ENOENT: no such file or directory, scandir 'node_modules'
at Object.readdirSync (node:fs:1525:3)
at getMetadata (/home/runner/work/aceik-sandpit-xmc/aceik-sandpit-xmc/src/rendering/node_modules/@sitecore-jss/sitecore-jss-dev-tools/dist/cjs/templating/metadata.js:15:31)
at generateMetadata (/home/runner/work/aceik-sandpit-xmc/aceik-sandpit-xmc/src/rendering/apps/aceik-demo/scripts/generate-metadata.ts:13:41)
at Object.<anonymous> (/home/runner/work/aceik-sandpit-xmc/aceik-sandpit-xmc/src/rendering/apps/aceik-demo/scripts/generate-metadata.ts:10:1)
at Module._compile (node:internal/modules/cjs/loader:1364:14)
at Module.m._compile (/home/runner/work/aceik-sandpit-xmc/aceik-sandpit-xmc/src/rendering/node_modules/ts-node/src/index.ts:1618:23)
at Module._extensions..js (node:internal/modules/cjs/loader:1422:10)
at Object.require.extensions.<computed> [as .ts] (/home/runner/work/aceik-sandpit-xmc/aceik-sandpit-xmc/src/rendering/node_modules/ts-node/src/index.ts:1621:12)
at Module.load (node:internal/modules/cjs/loader:1203:32)
at Function.Module._load (node:internal/modules/cjs/loader:1019:12) {
errno: -2,
syscall: 'scandir',
code: 'ENOENT',
path: 'node_modules'
}
npm error Lifecycle script `bootstrap` failed with error:
npm error Error: command failed
npm error in workspace: @aceik-demo/[email protected]
npm error at location: /home/runner/work/aceik-sandpit-xmc/aceik-sandpit-xmc/src/rendering/apps/aceik-demo
Error: Process completed with exit code 1.
To Reproduce
- npx create-sitecore-jss nextjs,nextjs-sxa,nextjs-multisite,nextjs-xmcloud
- Configure the structure into an npm workspace per https://docs.npmjs.com/cli/v10/using-npm/workspaces then run npm install so that the node_modules folder doesn't exist in the same directory as the app, but is instead in a parent folder
- npm run build
Expected Behavior
Build success
Possible Fix
Update https://github.com/Sitecore/jss/blob/8c23ac3af2341d0115268349581891fd9d049ebd/packages/sitecore-jss-dev-tools/src/templating/metadata.ts to have better error handling
Provide environment information
Sitecore Version: XM Cloud JSS Version: 22.0.0 Browser Name and version: Chrome latest Operating System and version (desktop or mobile): Windows 11 Link to your project (if available): n/a