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

Lerna cant publish if two workspaces that depend on each other change #3493

Open
joezappie opened this issue Jan 12, 2023 · 5 comments
Open

Comments

@joezappie
Copy link

Current Behavior

If I have package A that depends on package B and I change package b, lerna fails because it calls npm install. Since package B's version changed, npm seems to not be able to track that its a local package anymore and instead tries to get it from the registry.

Expected Behavior

This very well might just be chalked up to an npm issue (since NPM is throwing the error) but I can't see what I'm trying to do as uncommon so either there's a configuration that I'm missing or there needs to be a way to customize the order everything gets published?

Workaround

npx lerna version
npm i b -w /a
Manual git commit
npx lerna publish --no-private --skip-git 

Steps to Reproduce

  1. Create a project with two workspaces a & b
  2. npm i b -w a
  3. Run npx lerna publish
  4. Make a change to package b
  5. Run npx lerna publish
    2nd time it should fail as package a's package.json is updated to the version pre package b getting published

Failure Logs / Configuration

lerna.json

{
  "$schema": "node_modules/lerna/schemas/lerna-schema.json",
  "useWorkspaces": true,
  "version": "1.0.0-alpha.11"
}

lerna-debug.log

0 verbose cli [
0 verbose cli   'C:\\Program Files\\nodejs\\node.exe',
0 verbose cli   'C:\\Users\\joe.jankowiak\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
0 verbose cli   'install',
0 verbose cli   '--package-lock-only',
0 verbose cli   '--ignore-scripts'
0 verbose cli ]
1 info using npm@8.4.1
2 info using node@v16.13.0
3 timing npm:load:whichnode Completed in 0ms
4 timing config:load:defaults Completed in 2ms
5 timing config:load:file:C:\Users\joe.jankowiak\AppData\Roaming\npm\node_modules\npm\npmrc Completed in 3ms
6 timing config:load:builtin Completed in 3ms
7 timing config:load:cli Completed in 2ms
8 timing config:load:env Completed in 1ms
9 timing config:load:file:C:\Users\joe.jankowiak\projects\motionjs\.npmrc Completed in 0ms
10 timing config:load:project Completed in 1ms
11 timing config:load:file:C:\Users\joe.jankowiak\.npmrc Completed in 0ms
12 timing config:load:user Completed in 0ms
13 timing config:load:file:C:\Users\joe.jankowiak\AppData\Roaming\npm\etc\npmrc Completed in 1ms
14 timing config:load:global Completed in 1ms
15 timing config:load:validate Completed in 2ms
16 timing config:load:credentials Completed in 0ms
17 timing config:load:setEnvs Completed in 1ms
18 timing config:load Completed in 14ms
19 timing npm:load:configload Completed in 14ms
20 timing npm:load:setTitle Completed in 1ms
21 timing config:load:flatten Completed in 3ms
22 timing npm:load:display Completed in 3ms
23 verbose logfile C:\Users\joe.jankowiak\AppData\Local\npm-cache\_logs\2023-01-11T23_57_28_184Z-debug-0.log
24 timing npm:load:logFile Completed in 7ms
25 timing npm:load:timers Completed in 0ms
26 timing npm:load:configScope Completed in 0ms
27 timing npm:load Completed in 26ms
28 timing arborist:ctor Completed in 0ms
29 silly logfile start cleaning logs, removing 1 files
30 timing idealTree:init Completed in 701ms
31 timing idealTree:userRequests Completed in 1ms
32 silly idealTree buildDeps
33 timing idealTree:#root Completed in 1ms
34 silly fetch manifest @motion/core@^1.0.0-alpha.11
35 http fetch GET 200 https://npm.lime-rock.com/@motion%2fcore 736ms (cache updated)
36 silly placeDep packages/client @motion/core@ OK for: @motion/client@1.0.0-alpha.11 want: ^1.0.0-alpha.11
37 timing idealTree:packages/client Completed in 743ms
38 timing idealTree:packages/config Completed in 0ms
39 timing idealTree:packages/core Completed in 0ms
40 timing idealTree:packages/data-cache Completed in 0ms
41 timing idealTree:packages/serial Completed in 0ms
42 timing idealTree:packages/socket.io Completed in 0ms
43 timing idealTree:packages/winston Completed in 0ms
44 timing idealTree:packages/client/node_modules/@motion/core Completed in 0ms
45 timing idealTree:buildDeps Completed in 747ms
46 timing idealTree:fixDepFlags Completed in 11ms
47 timing idealTree Completed in 1461ms
48 timing command:install Completed in 1464ms
49 verbose type range
50 verbose stack @motion/core: No matching version found for @motion/core@^1.0.0-alpha.11.
50 verbose stack     at module.exports (C:\Users\joe.jankowiak\AppData\Roaming\npm\node_modules\npm\node_modules\npm-pick-manifest\index.js:209:23)
50 verbose stack     at C:\Users\joe.jankowiak\AppData\Roaming\npm\node_modules\npm\node_modules\pacote\lib\registry.js:118:26
50 verbose stack     at async Arborist.[nodeFromEdge] (C:\Users\joe.jankowiak\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:1082:19)
50 verbose stack     at async Arborist.[buildDepStep] (C:\Users\joe.jankowiak\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:951:11)
50 verbose stack     at async Arborist.buildIdealTree (C:\Users\joe.jankowiak\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:215:7)
50 verbose stack     at async Arborist.reify (C:\Users\joe.jankowiak\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\reify.js:152:5)
50 verbose stack     at async Install.exec (C:\Users\joe.jankowiak\AppData\Roaming\npm\node_modules\npm\lib\commands\install.js:157:5)
50 verbose stack     at async module.exports (C:\Users\joe.jankowiak\AppData\Roaming\npm\node_modules\npm\lib\cli.js:66:5)
51 verbose cwd C:\Users\joe.jankowiak\projects\motionjs
52 verbose Windows_NT 10.0.19045
53 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\joe.jankowiak\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install" "--package-lock-only" "--ignore-scripts"
54 verbose node v16.13.0
55 verbose npm  v8.4.1
56 error code ETARGET
57 error notarget No matching version found for @motion/core@^1.0.0-alpha.11.
58 error notarget In most cases you or one of your dependencies are requesting
58 error notarget a package version that doesn't exist.
59 verbose exit 1
60 timing npm Completed in 1852ms
61 verbose unfinished npm timer reify 1673481448567
62 verbose unfinished npm timer reify:loadTrees 1673481448567
63 verbose code 1
64 error A complete log of this run can be found in:
64 error     C:\Users\joe.jankowiak\AppData\Local\npm-cache\_logs\2023-01-11T23_57_28_184Z-debug-0.log

Environment

Environment info:

  System:
    OS: Windows 10 10.0.19045
    CPU: (8) x64 Intel(R) Core(TM) i7-4771 CPU @ 3.50GHz
  Binaries:
    Node: 16.13.0 - C:\Program Files\nodejs\node.EXE
    npm: 8.4.1 - C:\Program Files\nodejs\npm.CMD
  Utilities:
    Git: 2.30.2.
  npmPackages:
    lerna: ^6.4.0 => 6.4.0
@miltoncandelero
Copy link

miltoncandelero commented Jan 16, 2023

Same thing happening to me, I have a setup where I have a dependency tree and the leafs are either trying to use the old incompatible version from npm or the non-uploaded-yet version when running npx lerna publish during an npm install phase :(

Edit: Found the culprit:
https://github.com/lerna/lerna/tree/main/commands/version#--npm-client-args
During publish lerna calls version and version calls install to try to generate a new lockfile for that package.
Problem is, the lockfile can't be generated as the depending package hasn't been uploaded yet!

Not sure what the fix would be, if you are using only peerdeps adding "--legacy-peer-deps" might work but I have a hard dependency and that is giving me hell 🥲


Edit again! Found it!
#3455
It works with npm8, it seems is a wacky thing of npm9

@vidhyasome
Copy link

@joezappie
Copy link
Author

Thanks for digging into this more than I did. I decided to just switch to yarn and all is working well now. Seems like this might be an issue out of Lernas control and an issue should be raised with npm?

@wilyrus
Copy link

wilyrus commented Jan 30, 2023

Hello there! Having the save issue.
Recently updated from 5.0.0 to 6.4.1 (currently latest) and the build start to fail. The errors log the same as the topic sad. Can I help somehow to support the fixing? Maybe some more logs or some

@Kylir
Copy link

Kylir commented Mar 8, 2023

Hello. Same issue here. I tried to downgrade to npm 8 as suggested but this is not helping.
Switching to Yarn would be too much work.
Any advice on how to handle this? Any way to gently remind npm people that this is an issue?
Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants