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

getMetadata() is empty when using npm workspaces #2038

Open
jbluemink opened this issue Feb 7, 2025 · 1 comment
Open

getMetadata() is empty when using npm workspaces #2038

jbluemink opened this issue Feb 7, 2025 · 1 comment
Labels
backlog Issue/PR/discussion is reviewed and added to backlog for the further work 🐞 bug

Comments

@jbluemink
Copy link

Describe the Bug

The fix for #1812 is not working, when the Sitecore packages are coming from an monorepo.

In a Next.js project using a Turbo monorepo setup, Sitecore's Node module "sitecore-jss-dev-tools" function getMetadata() executes the following command:

npm query [name*=@sitecore] --workspaces false

However, this command fails to return any results when the dependencies are installed in a monorepo structure. Specifically, when running this command inside an app (apps/web), the Sitecore packages located in ./node_modules at the monorepo root are not detected.
workspaces should be true, not false for this situation.

To Reproduce

Steps to Reproduce:
Set up a Turbo monorepo with the following structure:

- apps/
    - web/
    - web2/
- node_modules/ (installed at monorepo root)
- packages

Define workspaces in package.json at the monorepo root:

{
  "private": true,
  "workspaces": [
    "apps/*",
    "packages/*"
  ]
}

The apps web, web2 has the jss modules as dependencies in the package.json:
"dependencies": {
"@sitecore-cloudsdk/events": "^0.4.0",
"@sitecore-cloudsdk/core": "^0.4.0",
"@sitecore-feaas/clientside": "^0.5.17",
"@sitecore-jss/sitecore-jss-nextjs": "~22.4.1",
"@sitecore/components": "^2.0.0",
}

Run npm install from the monorepo root.
Inside apps/web, execute:

npm query [name*=@sitecore] --workspaces false
Observe that the result is empty, even though @Sitecore packages exist in the monorepo and are used by app
note: without --workspaces false it works, or when running from the monrepo root,

Start up the app and check if the temp/metadata.json is empty.

Expected Behavior

The metadata.json should be generated correct.

Possible Fix

An option to (config) run the command with--workspaces true, or running from the monrepo root should fix this.

Provide environment information

  • JSS Version: 22.4.1
@yavorsk
Copy link
Contributor

yavorsk commented Feb 11, 2025

Thanks for the detailed submission, I am adding a ticket in our inbox to work on fixing this!

@yavorsk yavorsk added backlog Issue/PR/discussion is reviewed and added to backlog for the further work 🐞 bug and removed 🐞 bug labels Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backlog Issue/PR/discussion is reviewed and added to backlog for the further work 🐞 bug
Projects
None yet
Development

No branches or pull requests

2 participants