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

Pnpm publish doesn't work correctly with workspaces and npm 8.5.0 #4348

Closed
PieterBoeren opened this issue Feb 17, 2022 · 17 comments · Fixed by #4627
Closed

Pnpm publish doesn't work correctly with workspaces and npm 8.5.0 #4348

PieterBoeren opened this issue Feb 17, 2022 · 17 comments · Fixed by #4627

Comments

@PieterBoeren
Copy link

(I'm not sure if this issue is related to pnpm or npm)

pnpm version:

6.31.0

Code to reproduce the issue:

  1. Install the latest version of NPM (8.5.0)
  2. Create a project with workspaces, setup changesets and add dependencies from one workspace to another with something like "foo": "workspace:*"
  3. Run all the steps to create a new changeset and run pnpm publish -r

Expected behavior:

Workspace references have been replaced with an actual version in the published package.

Actual behavior:

The published package still contains "workspace:*" as version, making it not installable.

Additional information:

  • When I do a manual pnpm pack the version is being applied
  • Downgrading NPM to version 8.4.1 solves the issue
@zkochan
Copy link
Member

zkochan commented Feb 18, 2022

Maybe a bug in npm.

pnpm packs the tarball with the right manifest and then run the npm CLI to publish the prepared tarball:

const { status } = runNpm(opts.npmPath, ['publish', '--ignore-scripts', path.basename(tarballName), ...args], {

From the description it looks like npm CLI ignores the tarball and packs the folder on its own.

@lijie1129
Copy link

I have the same problem:

pnpm version:
6.32.1

Code to reproduce the issue:

  1. Install the latest version of NPM (8.5.3 and 8.3.1)
  2. Create a project with workspaces, setup changesets and add dependencies from one workspace to another with something like "foo": "workspace:*"
  3. Run all the steps to create a new changeset and run pnpm publish -r

Expected behavior:

Workspace references have been replaced with an actual version in the published package.

Actual behavior:
The published package still contains "workspace:*" as version, making it not installable.

Additional information:
When I do a manual pnpm pack the version is being applied
Downgrading/Upgrading NPM to version 8.4.1 does not solve the issue

@anuoua
Copy link

anuoua commented Apr 10, 2022

I have the same problem, the "workspace:^" not repleaced.

@zkochan zkochan self-assigned this Apr 10, 2022
@zkochan zkochan added this to the v7.0 milestone Apr 10, 2022
@zkochan
Copy link
Member

zkochan commented Apr 10, 2022

I think npm v7 works because we use npm v7 to publish pnpm and we don't have this issue.

@Amorites
Copy link

Meet same issue today with node v16.14.2 and npm 8.5.0, 7.24.2.
Downgrade to node v14.19.1 and npm 6.14.16 solved this.

@yue4u
Copy link

yue4u commented Apr 14, 2022

I encountered the same issue and downgrade to node v14.19.1 and npm 6.14.16 doesn't solved this for me.

uname -a: Linux home 5.16.16-arch1-1 #1 SMP PREEMPT Mon, 21 Mar 2022 22:59:40 +0000 x86_64 GNU/Linux

@zkochan
Copy link
Member

zkochan commented Apr 16, 2022

Maybe we could use a library from npm (https://github.com/npm/cli/tree/latest/workspaces/libnpmpublish) or from Yarn, to do the publishing.

@zkochan
Copy link
Member

zkochan commented Apr 16, 2022

I could not reproduce this issue.

@loynoir
Copy link

loynoir commented Apr 23, 2022

#4438

i used workaround, add .files field to package.json

@zkochan
Copy link
Member

zkochan commented Apr 27, 2022

🚢 6.32.11 and v7.0.0-rc.9

@yue4u
Copy link

yue4u commented Apr 27, 2022

@zkochan I can confirm my issue has been resolved with latest pnpm and node v18! Thanks a lot!

tantaman added a commit to vlcn-io/vlcn-orm that referenced this issue May 20, 2022
tantaman added a commit to tantaman/misc that referenced this issue May 24, 2022
@soeasyjx
Copy link

It happened to me, too. What's the solution

@ruscon
Copy link

ruscon commented Aug 26, 2023

Had the same issue from GitHub actions (monorepo)

[11:23:46 PM] [semantic-release] › ✘  An error occurred while running semantic-release: Error: Command failed with exit code 1: pnpm publish /home/runner/work/monorepo/monorepo/dist/libs/nestjs/logger-module --tag latest --registry https://npm.pkg.github.com/
 ERR_PNPM_CANNOT_RESOLVE_WORKSPACE_PROTOCOL  Cannot resolve workspace protocol of dependency "@xxx/common" because this dependency is not installed. Try running "pnpm install".
➜ pnpm -v
8.6.7

➜ node -v
v20.4.0

I found the problem and its solution:

  1. If use typescript and need to publish a package from the dist
  2. you must update your .npmrc
save-workspace-protocol=true
  1. Change all local versions from rolling to true type. Example: from workspace:^ to workspace:^1.0.0
    Read the documentation about it here
    Without it dist package must contain the node_modules folder.

@maerzhase
Copy link

currently experiencing the same with:

  • pnpm@8.6.9
  • npm@9.5.1
  • node@18.16.1

@ritz078
Copy link

ritz078 commented Nov 30, 2023

I am facing the same issue

@prodkt
Copy link

prodkt commented Dec 8, 2023

Encountering the same issue here as well.

@soeasyjx
Copy link

I've always had this problem

node
v20.10.0

pnpm
8.12.0

Can there be a complete solution

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

Successfully merging a pull request may close this issue.