lerna: Running lerna bootstrap does not install all dependencies
Expected Behavior
When running lerna bootstrap
all dependencies should be install in packages.
Current Behavior
If I run lerna bootstrap
and then run lerna start
to start all my clients and packages, I get the following error:
@raisalholdings/raisal-ui: 2263 modules
@raisalholdings/raisal-ui: ERROR in ../raisal-utils/src/reduxUtils.js
@raisalholdings/raisal-ui: Module not found: Error: Can't resolve 'redux-actions' in '/Users/scott/Develop/Raisal/2.0/raisal-clients/packages/raisal-utils/src'
@raisalholdings/raisal-ui: ERROR in ../raisal-utils/src/reduxUtils.js
@raisalholdings/raisal-ui: Module not found: Error: Can't resolve 'redux-optimistic-ui' in '/Users/scott/Develop/Raisal/2.0/raisal-clients/packages/raisal-utils/src'
If I cd into packages/raisal-ui
, and run yarn
, I get the following error:
error An unexpected error occurred: "ENOENT: no such file or directory, lstat '/Users/scott/Develop/Raisal/2.0/raisal-clients/packages/raisal-ui/node_modules/@raisalholdings/raisal-utils/node_modules/history/node_modules'".
...
But if I run yarn one more time, everything installs in raisal-ui and I can then run lerna run start
and everything starts fine.
Possible Solution
Install all deps or provide logs to debug
I have the following setup:
root/
clients/
packages/
lerna.json
package.json
lerna.json
{
"lerna": "2.5.1",
"packages": [
"clients/*",
"packages/*"
],
"npmClient": "yarn",
"version": "2.1.13"
}
Your Environment
Executable | Version |
---|---|
lerna --version |
2.5.1 |
npm --version |
6.0.0 |
yarn --version |
1.6.0 |
node --version |
v8.9.3 |
OS | Version |
---|---|
Sierra | 10.13.1 |
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 94
- Comments: 66 (6 by maintainers)
Commits related to this issue
- Fix lerna link https://github.com/lerna/lerna/issues/1457 — committed to expo/entity by wschurman 4 years ago
- Create tests.yml github action (#2) * Create tests.yml * Fix lerna link https://github.com/lerna/lerna/issues/1457 — committed to expo/entity by wschurman 4 years ago
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Thanks @scottmcpherson! I also came to this simple workaround:
So the
lerna exec npm install
command does the trick.This problem was fixed for our project by changing our “packages” path to include two asterisks instead of one. I just happened to get lucky on this one:
UPDATE: spoke a little too soon I guess, I get different results with successive runs of
lerna bootstrap
. The first run will install all deps for packages A and B, but not C and D. The second run will install all packages for A and D, but not B and C. It changes on every run. Runninglerna link && lerna exec npm install
seems to do the trick for now. Still investigating.Same here with lerna 4.0.0
so… is there any solution for this problem? 😢
Still going on 😦
This is still happening - any solution?
Problem still exist on Lerna 5.1.8.
I tried the workaround but
lerna exec -- npm install
ignores .npmrc file which is at root levelWe can’t believe in the continuation of such a bug
Although
lerna exec npm install
works fine. This problem still exist onlerna@3.22.1
Repro
I created a Docker container with instructions how to reproduce the issue: silvenon/lerna-bootstrap-issue. You can check out the failing (
lerna bootstrap
) vs successful (lerna exec yarn && lerna link
) script.@xpepermint What ended up working for us was creating a custom js bootstrap script and executing that using
yarn bootstrap
.The script is
scripts/bootstrap.js
:Replace
const RAISAL_UI_DIR = path.join(process.cwd(), 'packages', 'raisal-ui')
with the dir that needs the packages reinstalled.And then in my root package.json I added an npm script:
Same issues for us. Banging my head against a wall. Works fine on my Mac. Causing me issues on remote Ubuntu server or in a docker container.
I literally can’t debug without an actual reproduction. Telling me what your tree looks like is worthless without the actual contents of the package.json files.
For me,
lerna bootstrap --hoist
worked fine on my dev machine, but in my client’s facility it would only install top-level dependencies. Upgrading that system from Node 14.x to 16.x solved the problem.I had the same issue and the root cause was that some packages were not listed in the root package.json file (probably because they were not added using
npx lerna add
but manually). All packages in a monorepo should be listed in root package.json file:In case you want devDependencies to be installed, you have to make sure that NODE_ENV is not “production”
I ran into this when transitioning from workspaces and
yarn
->npm@6
. Withyarn
, I originally haduseWorkspaces
set totrue
in mylerna.json
, which I believe tells lerna to just defer toyarn
for installing and hoisting. When I removed that,lerna
properly installed externals for all packages as intended.TL;DR: It was my fault. Make sure
useWorkspaces
inlerna.json
is not set to true when usingnpm
as your npm client.This is actually the exact issue: https://github.com/lerna/lerna/issues/1457#issuecomment-812293323
I globally set
NODE_ENV
asproduction
in the CI runner and it literally messed up everythingAny ideea why I started receiving this error ?
lerna ERR! yarn install --mutex network:42424 --non-interactive exited 1 in ‘@pu/event-listeners’ lerna ERR! yarn install --mutex network:42424 --non-interactive stdout: lerna ERR! yarn install --mutex network:42424 --non-interactive stderr: error Package “” refers to a non-existing file ‘“D:\pu\packages\auth-service”’.
lerna ERR! yarn install --mutex network:42424 --non-interactive exited 1 in ‘@pu/event-listeners’ lerna WARN complete Waiting for 3 child processes to exit. CTRL-C to exit immediately. error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Facing the same issue with latest version of lerna…
14864 silly saveTree
-- ssf@0.10.2 14864 silly saveTree
– frac@1.1.2 14865 warn onlinewebapp@1.0.0 No repository field. 14866 verbose stack RangeError: Maximum call stack size exceeded 14866 verbose stack at RegExp.test (<anonymous>) 14866 verbose stack at isDepOptional (C:\Program Files\nodejs\node_modules\npm\lib\install\deps.js:428:45) 14866 verbose stack at failedDependency (C:\Program Files\nodejs\node_modules\npm\lib\install\deps.js:437:9) 14866 verbose stack at failedDependency (C:\Program Files\nodejs\node_modules\npm\lib\install\deps.js:453:9) 14866 verbose stack at failedDependency (C:\Program Files\nodejs\node_modules\npm\lib\install\deps.js:453:9) 14866 verbose stack at failedDependency (C:\Program Files\nodejs\node_modules\npm\lib\install\deps.js:453:9) 14866 verbose stack at failedDependency (C:\Program Files\nodejs\node_modules\npm\lib\install\deps.js:453:9) 14866 verbose stack at failedDependency (C:\Program Files\nodejs\node_modules\npm\lib\install\deps.js:453:9) 14866 verbose stack at failedDependency (C:\Program Files\nodejs\node_modules\npm\lib\install\deps.js:453:9) 14866 verbose stack at failedDependency (C:\Program Files\nodejs\node_modules\npm\lib\install\deps.js:453:9) 14866 verbose stack at failedDependency (C:\Program Files\nodejs\node_modules\npm\lib\install\deps.js:453:9) 14866 verbose stack at failedDependency (C:\Program Files\nodejs\node_modules\npm\lib\install\deps.js:453:9) 14866 verbose stack at failedDependency (C:\Program Files\nodejs\node_modules\npm\lib\install\deps.js:453:9) 14866 verbose stack at failedDependency (C:\Program Files\nodejs\node_modules\npm\lib\install\deps.js:453:9) 14866 verbose stack at failedDependency (C:\Program Files\nodejs\node_modules\npm\lib\install\deps.js:453:9) 14866 verbose stack at failedDependency (C:\Program Files\nodejs\node_modules\npm\lib\install\deps.js:453:9) 14867 verbose cwd D:\BranchWebApp\branchwebapp\packages\onlinewebapp 14868 verbose Windows_NT 10.0.18362 14869 verbose argv “C:\Program Files\nodejs\node.exe” “C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js” “install” “–global-style” 14870 verbose node v12.16.3 14871 verbose npm v6.14.4 14872 error Maximum call stack size exceeded 14873 verbose exit [ 1, true ]@ericsvendsen solution worked, thank you!
I ended up adding a
postinstall
bootstrap
script to the root’spackage.json
as follows:This way, I get to do my normal npm install and once it finishes, I will execute
npm run bootstrap
, which in turn will execute thelerna
bootstrapping along with installing all my dependencies in all of my packages.NOTE: Making this to be in the
postinstall
lifecycle script was not a good idea because when someone installs the dependency it will execute thepostinstall
script, and will cause errors@ktalebian I had the same issue… what i end up doing is:
–hoist will install all external dependencies in the root node_modules and then i used root node_modules packages in all my sub packages package.json -> scripts section. For example from one sub package script i did:
Adding
to one of our package create the problem for us
I ran into the same problem today as well. Got more or less the same error message. In my case it was the a mistake on my side – obviously 😆
I have created a new package:
Then I added this new package as a dependency to an already existing package:
existing-package/package.json:
However,
new-package
was created with version 1.0.0. Thuslerna bootstrap
was not able to find it.In my case adjusting the version number fixed the issue. Not sure if this is the root cause in your specific case…
~Can we please reopen? It really does not install package dependencies on Ubuntu. Using
npm
afterlerna link convert
.lerna exec -- npm install
works fine. Is this by design?~It works now, but I cannot remember specifically what I did to resolve this. Since I was migrating from
yarn
, I had to remove theworkspaces
reference from mypackage.json
- After that, I tried with a fresh clone and it seemed to work.My issue seems the same, quite hard to share. B depends on A.
Doing
lerna exec -- npm i && lerna link
does what I want. Frombootstrap
description@evocateur does this mean that the external dependencies of the linked packages will not be installed? Edit: I’m not hoisting.