vsce publish fails - VS Code Extension using pnpm/yarn
Asked Answered
C

3

6

Versions:

  • vsce version 1.71.0
  • node version v10.15.3
  • npm version 6.4.1

vsce publish fails with the below message:

Executing prepublish script 'npm run vscode:prepublish'...

[email protected] vscode:prepublish C:\Projects\VS Code Extensions\sfdx-command-builder
npm run compile

[email protected] compile C:\Projects\VS Code Extensions\sfdx-command-builder
tsc -p ./

ERROR Command failed: npm list --production --parseable --depth=99999 npm ERR! missing: [email protected], required by [email protected] npm ERR! missing: [email protected], required by [email protected] npm ERR! missing: [email protected], required by [email protected] npm ERR! missing: [email protected], required by [email protected] npm ERR! missing: [email protected], required by [email protected] npm ERR! missing: [email protected], required by [email protected] npm ERR! missing: [email protected], required by [email protected] npm ERR! missing: [email protected], required by [email protected] npm ERR! missing: [email protected], required by [email protected] npm ERR! missing: [email protected], required by [email protected] npm ERR! missing: [email protected], required by [email protected] npm ERR! missing: [email protected], required by [email protected] npm ERR! missing: [email protected], required by [email protected] npm ERR! missing: [email protected], required by [email protected] npm ERR! missing: [email protected], required by [email protected] npm ERR! missing: [email protected], required by [email protected] npm ERR! missing: [email protected], required by [email protected] npm ERR! missing: [email protected], required by [email protected] npm ERR! missing: [email protected], required by [email protected] npm ERR! missing: [email protected], required by [email protected] npm ERR! missing: [email protected], required by [email protected] npm ERR! missing: [email protected], required by [email protected] npm ERR! missing: [email protected], required by [email protected] npm ERR! missing: [email protected], required by [email protected] npm ERR! missing: [email protected], required by [email protected] npm ERR! missing: [email protected], required by [email protected] npm ERR! missing: [email protected], required by [email protected] npm ERR! missing: [email protected], required by [email protected] npm ERR! missing: [email protected], required by [email protected] npm ERR! missing: [email protected], required by [email protected] npm ERR! missing: [email protected], required by [email protected] npm ERR! missing: [email protected], required by [email protected] npm ERR! missing: [email protected], required by [email protected]

Cyrillic answered 18/1, 2020 at 8:47 Comment(1)
Edit the question to reveal your package.json.Lorenzen
D
8

This happens because the extension's linker fails to resolve the dependencies.

To fix it do the following depending on which node package manager your repo uses:

  • yarn repo:

    vsce publish --yarn -p $my_token
    
  • pnpm repo:

    1. if you have no runtime dependencies you can keep it simple, just add this to your package.json

      "scripts": {
          "package": "pnpm vsce package --no-dependencies",
          "publish": "pnpm vsce publish --no-dependencies"
      }
      

      or run the command vsce publish patch --no-dependencies (use minor or major instead of patch as needed, see semver)

    2. if you have runtime dependencies you need to bundle them first, so additionally to (1) also add this to your package.json

      "scripts": {
          "vscode:prepublish": "npm run esbuild-base -- --minify",
          "esbuild-base": "esbuild ./src/extension.ts --bundle --outfile=out/main.js --external:vscode --format=cjs --platform=node"
      }
      

For either case you'll obviously need to install vsce with

pnpm i -D vsce # or `yarn add -D vsce`

and in the 2nd pnpm case you'll also need esbuild too

pnpm i -D esbuild

See more info in the related Github issue.

Damron answered 12/5, 2023 at 6:16 Comment(0)
P
1

Have you tried to run npm install before running vsce publish?

I experienced the issue when using yarn. The solution for me was to add --yarn to the command:

vsce publish --yarn -p $my_token

Source: @joaomoreno's comment in https://github.com/Microsoft/vscode-vsce/issues/246#issuecomment-396528264

Pipkin answered 19/6, 2020 at 9:22 Comment(1)
What if I'm using pnpm? I tried --pnpm and it gives me error: unknown option '--pnpm'Damron
S
0

If you are using javascript which is seemingly a less popular choice and facing this error then try this

npm i --save-dev webpack webpack-cli

It solved my error and let me publish by adding desired dependencies.

Studdingsail answered 22/1 at 1:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.