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] Workspaces: 'Prepare: build' leads to error on npm install in base directory #3972

Open
1 task done
penguinsAreFunny opened this issue Nov 2, 2021 · 2 comments
Open
1 task done
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release

Comments

@penguinsAreFunny
Copy link

penguinsAreFunny commented Nov 2, 2021

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

base-dir
packages/
package1/
package.json -> dependency: package2
package2/
...
package.json
workdir: ["packages/*"]

I have prepare scripts in each package which should build the package-project. On npm install in base directory npm install of each package will be run and therefore also the prepare scripts. At this point it seems though that the dependencies are not resolved correctly leading to an error on npm install and therefore dismissing further installations. The missing dependencies are locally installed in the node_modules directory of the packages. Therefore this should not lead to an error.

Npm install, npm run build, npm run prepare work fine from the package´s directory.

Might it be that the npm run prepare build is not run with cwd: package? Or how does npm install resolve the dependencies and dependency versions of each package. For some packages it seems that different versions of dependend packages are available but not the local installed dependency of the package.

This might be correlated with a few other bug reports.

Example error message
SonarQubePredecessorsQuantifier/cache/cache.ts: Cannot find module: This module is locally installed in the package´s node_modules directory. Npm install, npm build works fine with cwd: package.
npm ERR! code 2 npm ERR! path C:\ma-implementation-3\implementation\packages\bugFinder-commitPath-quantifier-sonarqubePredecessors npm ERR! command failed npm ERR! command C:\Windows\system32\cmd.exe /d /s /c npm run build npm ERR! > [email protected] build npm ERR! > npm run clean && tsc --project . npm ERR! npm ERR! npm ERR! > [email protected] clean npm ERR! > rimraf ./dist npm ERR! npm ERR! src/sonarQubePredecessorsQuantifier/cache/cache.ts(3,36): error TS2307: Cannot find module 'bugfinder-commitpath-quantifier-sonarqube' or its corresponding type declarations. npm ERR! src/sonarQubePredecessorsQuantifier/measurement/Elements.ts(1,23): error TS2307: Cannot find module 'bugfinder-commitpath-quantifier-sonarqube' or its corresponding type declarations. npm ERR! src/sonarQubePredecessorsQuantifier/measurement/SonarQubePredecessorMeasurement.ts(1,55): error TS2307: Cannot find module 'bugfinder-commitpath-quantifier-sonarqube' or its corresponding type declarations. npm ERR! src/sonarQubePredecessorsQuantifier/measurement/Visitors.ts(1,23): error TS2307: Cannot find module 'bugfinder-commitpath-quantifier-sonarqube' or its corresponding type declarations. npm ERR! src/sonarQubePredecessorsQuantifier/sonarQubePredecessorsQuantifier.ts(10,57): error TS2307: Cannot find module 'bugfinder-commitpath-quantifier-sonarqube' or its corresponding type declarations.

Expected Behavior

Npm install works fine.
Npm install of each package installs with cwd: package and the dependencies of the package`s package.json are locally used.

No response

Environment

  • OS: Windows 10
  • Node: 14.17.0
  • npm: 8.1.0
@penguinsAreFunny penguinsAreFunny added Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release labels Nov 2, 2021
@nlf
Copy link
Contributor

nlf commented May 31, 2022

The missing dependencies are locally installed in the node_modules directory of the packages

does this mean you've individually run npm install within each workspace and installed all of the workspace's dependencies within their own dir? if so, i would recommend deleting those node_modules directories in your workspaces and running npm install from the root project. npm will appropriately deduplicate dependencies for your workspaces as well and only nest what it absolutely needs to, this is far more likely to give you the dep tree you actually need.

give that a shot and let us know if it doesn't work!

@olalonde
Copy link

Having a similar issue when running npm rebuild in the root of my workspace. It fails at some prepare scripts.

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

No branches or pull requests

3 participants