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

[BUG] npm ci workspace broke node_modules #7692

Open
2 tasks done
leppaott opened this issue Jul 30, 2024 · 0 comments
Open
2 tasks done

[BUG] npm ci workspace broke node_modules #7692

leppaott opened this issue Jul 30, 2024 · 0 comments
Labels
Bug thing that needs fixing Needs Triage needs review for next steps

Comments

@leppaott
Copy link

leppaott commented Jul 30, 2024

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • I am using the latest npm

Current Behavior

#7490 introduces "cleaning" of workspaces during npm ci on root package however it also wipes the workspace node_modules incorrectly since they are not re-installed anywhere. #7490 (comment)

TS compilations need those modules. This should be considered with more thought. It's now doing the clean part yes but it's not doing the install part on clean-install i.e. install the node_modules for the workspaces since this isn't how the npm i --workspaces=true e.g. works (they just link the workspace etc maybe there's room to improve too).

Now you cannot run a workspace script that calls a binary after the clean-install which you surely can if you just use install here. If you do a clean-install on the workspace it has the binary, after which you do a clean-install on the root it for some reason wipes the workspace's packages.

You can test my issue of having let say copyfiles package on postinstall for a workspace module. Interestingly postinstall scripts are indeed run for workspaces but modules don't get re-installed and thus don't exist anywhere.

And you should get following when running npm ci for the parent module:

npm error sh: 1: copyfiles: not found

while workspace package.json looks something like:

"scripts": {
    "postinstall": "copyfiles . .",
  },
  "dependencies": {
    "copyfiles": "^2.4.1",

this shouldn't happen since the workspace module is installed earlier... But now npm ci breaks it.
Bad example but to illustrate our workflow. Also to mention the file structure is ../workspace so the workspace isn't inside the service which might affect binary usage too.

Expected Behavior

Earlier behavior before 10.8.1: i.e. if the workspace has node_modules it should be left as it to allow building succeed.
Or by default install workspace modules too. Or only explicitly when given --workspaces=true. How about --workspaces=false should it not disable any of this?

Steps To Reproduce

Environment

  • npm: 10.8.1
  • Node.js: 20.15.0
@leppaott leppaott added Bug thing that needs fixing Needs Triage needs review for next steps labels Jul 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Needs Triage needs review for next steps
Projects
None yet
Development

No branches or pull requests

1 participant