vscode-extensions

why failed to use vsce to package vs code extension


I just migrated may dev env from windows 10 to windows 11. But got a failure when trying to package the extension with vsce.

C:\Users\vrusr\Workspace\Bitbucket\auto-prompts>vsce package
C:\Users\vrusr\AppData\Roaming\npm\node_modules\vsce\node_modules\undici\lib\core\util.js:623
  const listeners = (obj[kListeners] ??= [])
                                     ^^^

SyntaxError: Unexpected token '??='
    at wrapSafe (internal/modules/cjs/loader.js:1029:16)
    at Module._compile (internal/modules/cjs/loader.js:1078:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1143:10)
    at Module.load (internal/modules/cjs/loader.js:979:32)
    at Function.Module._load (internal/modules/cjs/loader.js:819:12)
    at Module.require (internal/modules/cjs/loader.js:1003:19)
    at require (internal/modules/cjs/helpers.js:107:18)
    at Object.<anonymous> (C:\Users\vrusr\AppData\Roaming\npm\node_modules\vsce\node_modules\undici\lib\dispatcher\client.js:8:14)
    at Module._compile (internal/modules/cjs/loader.js:1114:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1143:10)

C:\Users\vrusr\Workspace\Bitbucket\auto-prompts>

I am using Node 14.21.3. And vsce@2.14.0.

This works on my windows 10 box, but return above error on windows 11.

Can someone let me know the cause?

Thanks b


Solution

  • Node.js 14 does not support the ??= operator syntax, which is being used in a dependency of vsce. Your windows 10 setup likely had a newer version of Node.js installed.

    Try upgrading Node.js to the latest LTS version and running vcse package again.