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 install - workspaces not installing dependencies as expected #3609

Closed
1 task done
nhall97 opened this issue Aug 4, 2021 · 1 comment
Closed
1 task done
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 7.x work is associated with a specific npm 7 release

Comments

@nhall97
Copy link

nhall97 commented Aug 4, 2021

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

I have the following configuration

  "workspaces": [
    "packages\\sfdx-core-package",
    "packages\\sfdx-bonus-package"
  ],

When I run 'npm install' on my local environment - it generates a package-lock with 982 dependencies.

In my CI (using Google Cloudbuild)

I run

  - name: node
    entrypoint: npm
    args: ['install']

which runs the 'npm install' command.

But get the following output:


  run `npm fund` for details
1 package is looking for funding

added 1 package, and audited 2 packages in 574ms

I expect that to be much bigger, based off the dependencies in the 2 workspace package.json files.

NPM doesn't seem to be recognising the workspaces, as when I run 'npm run test --ws' as part of the CI build, the following error occurs:

Again this works again locally, but not in the CI.

npm ERR!     /builder/home/.npm/_logs/2021-08-04T15_00_23_169Z-debug.log
npm ERR! A complete log of this run can be found in:

npm ERR! No workspaces found!

Expected Behavior

npm install from the package, should create package lock correctly from the workspace directories
'npm run test --ws' should run test on both packages, as it does locally.

Steps To Reproduce

Below example is an opensource project, that works locally, but does not work on a CI.

  1. https://github.com/nhall97/sfdx-monorepo-workspace
  2. npm install
  3. Expects work correctly

Environment

CI configuration:

  • Node: docker.io/library/node:16.6.1
  • npm: 7.20.3
@nhall97 nhall97 added Bug thing that needs fixing Needs Triage needs review for next steps Release 7.x work is associated with a specific npm 7 release labels Aug 4, 2021
@nhall97 nhall97 changed the title [BUG] npm install - not installing dependencies as expected [BUG] npm install - working not installing dependencies as expected Aug 4, 2021
@nhall97 nhall97 changed the title [BUG] npm install - working not installing dependencies as expected [BUG] npm install - workspaces not installing dependencies as expected Aug 4, 2021
@wraithgar
Copy link
Member

This is due to the fact that lifecycle scripts in workspaces don't run when they're installed. You will need to manually run the prepare script in each workspace in order for husky to run, and for it to build the things your script is expecting to be there.

See #4412 and #3598 for more context

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 Release 7.x work is associated with a specific npm 7 release
Projects
None yet
Development

No branches or pull requests

2 participants