Vignaesh Ram
Vignaesh Ram

Reputation: 181

vsce publish fails - VS Code Extension using pnpm/yarn

Versions:

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]

Upvotes: 7

Views: 3277

Answers (3)

maninak
maninak

Reputation: 2726

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.

Upvotes: 8

Amina Nasrin
Amina Nasrin

Reputation: 89

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.

Upvotes: 0

UltraMaster
UltraMaster

Reputation: 1124

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

Upvotes: 1

Related Questions