storyblok / field-plugin

Create and deploy Storyblok Field Plugin
https://www.storyblok.com/docs/plugins/field-plugins/introduction
MIT License
25 stars 3 forks source link

Multirepo pnpm install fails after creation #329

Closed hoersamu closed 10 months ago

hoersamu commented 11 months ago

Describe the bug Create fails for pnpm due to missing version constraint for the package manager field in the package.json

Error:

✖ Running `pnpm install`..
file:///Users/xxx/.npm/_npx/ca700ea613ccf9d4/node_modules/execa/lib/error.js:59
        error = new Error(message);
                ^

Error: Command failed with exit code 1: pnpm install
Usage Error: Invalid package manager specification in ../../package.json; expected a semver version

$ pnpm ...
    at makeError (file:///Users/xxx/.npm/_npx/ca700ea613ccf9d4/node_modules/execa/lib/error.js:59:11)
    at handlePromise (file:///Users/xxx/.npm/_npx/ca700ea613ccf9d4/node_modules/execa/index.js:119:26)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async S (/Users/xxx/.npm/_npx/ca700ea613ccf9d4/node_modules/@storyblok/field-plugin-cli/dist/main.cjs:1:1594)
    at async R (/Users/xxx/.npm/_npx/ca700ea613ccf9d4/node_modules/@storyblok/field-plugin-cli/dist/main.cjs:7:885)
    at async Pe (/Users/xxx/.npm/_npx/ca700ea613ccf9d4/node_modules/@storyblok/field-plugin-cli/dist/main.cjs:15:77)
    at async Te (/Users/xxx/.npm/_npx/ca700ea613ccf9d4/node_modules/@storyblok/field-plugin-cli/dist/main.cjs:17:401)
    at async Command.<anonymous> (/Users/xxx/.npm/_npx/ca700ea613ccf9d4/node_modules/@storyblok/field-plugin-cli/dist/main.cjs:20:3468) {
  shortMessage: 'Command failed with exit code 1: pnpm install',
  command: 'pnpm install',
  escapedCommand: 'pnpm install',
  exitCode: 1,
  signal: undefined,
  signalDescription: undefined,
  stdout: 'Usage Error: Invalid package manager specification in ../../package.json; expected a semver version\n' +
    '\n' +
    '$ pnpm ...',
  stderr: '',
  failed: true,
  timedOut: false,
  isCanceled: false,
  killed: false
}

To Reproduce Steps to reproduce the behavior:

  1. run npx @storyblok/field-plugin-cli@latest
  2. Select pnpm
  3. Select multirepo, vue 3 (looking at the code this problem probably exists for multiple templates)
  4. See error

Expected behavior Pnpm install starts and succeds.

Desktop (please complete the following information):

eunjae-lee commented 11 months ago

Hello @hoersamu Thanks for reporting this issue. I just tested it and it actually worked on my machine.

both worked. I'm using Node 18.16.0 with pnpm 8.6.7, which isn't that different from yours.

Maybe could you post your package.json that possibly could've caused this issue of Invalid package manager specification in ../../package.json; expected a semver version error"?

hoersamu commented 11 months ago

Hey @eunjae-lee

I'll post the package.json later today. I tested it on two MacOs devices (one with nvm and corepack and one with "normal" node and pnpm installations). I'll try it with my Win PC later today and update my report.

hoersamu commented 10 months ago

Hey @eunjae-lee

Sorry for the delay. This is the root package.json file: package.json

I can't reproduce the polyrepo problem but the monorepo problem is still reproducible.

I asked my collegues to test this too: Node 18.15.0 + pnpm 8.12.0 -> No Problem Node 18.15.0 + pnpm 8.14.0 -> Error Node 18.15.0 + pnpm 8.6.11 -> Error Node 18.15.0 + pnpm 8.6.5 -> Error

There is also a schema warning in the package.json:

String does not match the pattern of "(npm|pnpm|yarn|bun)@\d+\.\d+\.\d+(-.+)?".

I looked up the spec (https://nodejs.org/api/packages.html#packagemanager) and the officially need name@version.

hoersamu commented 10 months ago

Hm this issue might be related to corepack. Most of my organization has corepack enabled so this might explain why we can all reproduce it with various pnpm versions.

eunjae-lee commented 10 months ago

@hoersamu Oh, I don't have corepack enabled. It might be the reason why I cannot reproduce it.

Do you think if we update the package.json to include pnpm@8.12.0 instead of pnpm, will it solve your problem?

hoersamu commented 10 months ago

@eunjae-lee Honestly i would remove it. This field in the package.json is marked as experimental and corepack specific.

If you want to keep it you could also set it to * (or latest or stable).

eunjae-lee commented 10 months ago

@eunjae-lee Honestly i would remove it. This field in the package.json is marked as experimental and corepack specific.

If you want to keep it you could also set it to * (or latest or stable).

Thanks for the feedback. Then could you give it a test by removing that field, and see if it works for you?

hoersamu commented 10 months ago

Hey @eunjae-lee * Apparently star also doesn't work but I created a PR where I set the pnpm version to the latest stable release. This fixes the issue.