For some extension projects, people may use a bundle file instead of the regular node_modules.
Even if we do that, we may get some errors, when running
npm list --production --parseable --depth=99999 --link=true
Since vsce always tries to list/find dependencies as can be seen in issue #246 .
The workaround suggest is to use --yarn, since it will check for a yarn.lock file, and if it don't find, nothing happens and vsce doesn't run npm list command.
Adding node_modules to ignore file won't help because this happens after we already tried to run npm list
I propose here to add an option to package called --ignoreDependencies, so we don't run the getNpmDependencies and instead just return [cwd] in getDependencies
Can you show me what a _bundle file_ means?
Like in here:
https://code.visualstudio.com/api/working-with-extensions/bundling-extension#configure-webpack
output: {
// the bundle is stored in the 'dist' folder (check package.json), 馃摉 -> https://webpack.js.org/configuration/output/
path: path.resolve(__dirname, 'dist'),
filename: 'extension.js',
libraryTarget: 'commonjs2',
devtoolModuleFilenameTemplate: '../[resource-path]'
},
The only thing that needs to be packaged is extension.js (bundle with all the required libs).
But vsce still tries to look at node_modules even if it is not necessary (and sometimes this can cause issues).
As mentioned here, once you start bundling, you should simply ignore node_modules using the .vscodeignore file.
@joaomoreno That does not solve the issue. I already have node_modules in my .vscodeignore.
Even if node_modules is included in .vscodeignore , npm list is still run. That's the problem.
Check the following files:
Ah the problem is that it still runs, and it throws an error? What error does it throw, btw?
It doesn't necessarily always show an error. But in some scenarios it can show an error like the one described in the issue https://github.com/microsoft/vscode-vsce/issues/246 . (the workaround proposed is to use --yarn, that doesn't use npm list.
My error looks like the one in the issue, but it is not the same one (although it is also caused by npm list). Unfortunately I can't post my exact error right now (I am not working in the project that have the issue).
My packaging is working perfectly, but npm list show an error for some dependency that is not really important and that forbids packaging.
Actually, I've never even run npm list before I found this issue.
So... npm install works without an issue, yet npm list fails? It would be great to see the error. Also, which npm version are you on?
I think this will be useful to bypass yarn's packaging bug via workaround explained in #432 too. --ignoreDependencies would skip npm list check against modules installed through yarn, that may have mismatched node_modules structure with npm.
Npm version, 6.13.4, node version v12.16.1
npm install works without an issue.
bundle.
npm run package (node ./node_modules/vsce/out/vsce package")
Command failed: npm list --production --parseable --depth=99999 --loglevel=error
npm ERR! peer dep missing: @material-ui/core@^3.2.0, required by [email protected]
npm ERR! peer dep missing: @material-ui/icons@^3.0.1, required by [email protected]
Same issue
ERROR Command failed: npm list --production --parseable --depth=99999 --loglevel=error
npm ERR! extraneous: [email protected] C:\Source\GitHub\resxpress\node_modules\make-fetch-happen\node_modules\p-map
npm ERR! missing: p-map@^4.0.0, required by [email protected]
npm run webpack succeeds but this fails
I'm having the exact same issue when using a Github Action to deploy a VSCode extension:
It's in a monorepo using Lerna, and my VSCode extension package depends on another library in the repository:
- packages/
- library/
- vscode-extension/ # (depends on library)
There are 3 main jobs:
install (using lerna link, so library is loaded from folder directly)build (using webpack, and get a bundle, so no further need for node_modules after that)publish (using vsce, which fails because node_modules are not present)In the publish job, I should not need to load the node_modules cache, which even if fast, is not useful in the process.
So IMO this --ignoreDependencies flag would be useful.
I think a simple solution here would be to say that if node_modules is present in the .vscodeignore file, there should be no check done about the dependencies.
I think the flag is useful because I use yarn 2 which has no list command
I was able to work around the issue by downgrading to npm@6 and recreating package-lock.json not to use lockfile version 2. Seems like a problem with the new lockfile version introduced with npm@7.
@joaomoreno do you still think we need more info? I see the label is still there.
what information do we need for this? I've run into the same problem. I have an extension that includes other projects that are referenced directly during development, like below.
npm install works fine, but the npm list --production --parseable --depth=99999 --loglevel=error causes problems because it is finding all the dependencies from the other projects as "extraneous"
"dependencies": {
"@f5devcentral/f5-fast-core": "^0.7.0",
"@types/js-yaml": "^3.12.6",
"axios": "^0.21.1",
"f5-conx-core": "file:../f5-conx-core",
"f5-corkscrew": "file:../f5-corkscrew",
"js-yaml": "^3.14.1",
"keytar": "^6.0.1"
}
ted@r2d2:~/projects/vscode-f5$ vsce package ?
Executing prepublish script 'npm run vscode:prepublish'...
> [email protected] vscode:prepublish /home/ted/projects/vscode-f5
> npm run compile
> [email protected] compile /home/ted/projects/vscode-f5
> tsc -p ./
ERROR Command failed: npm list --production --parseable --depth=99999 --loglevel=error
npm ERR! extraneous: @types/[email protected] /home/ted/projects/vscode-f5/node_modules/f5-corkscrew/node_modules/@types/assert
npm ERR! extraneous: @types/[email protected] /home/ted/projects/vscode-f5/node_modules/f5-corkscrew/node_modules/@types/mocha
npm ERR! extraneous: @typescript-eslint/[email protected] /home/ted/projects/vscode-f5/node_modules/f5-corkscrew/node_modules/@typescript-eslint/eslint-plugin
npm ERR! extraneous: @typescript-eslint/[email protected] /home/ted/projects/vscode-f5/node_modules/f5-corkscrew/node_modules/@typescript-eslint/parser
npm ERR! extraneous: [email protected] /home/ted/projects/vscode-f5/node_modules/f5-corkscrew/node_modules/assert
npm ERR! extraneous: [email protected] /home/ted/projects/vscode-f5/node_modules/f5-corkscrew/node_modules/eslint
npm ERR! extraneous: [email protected] /home/ted/projects/vscode-f5/node_modules/f5-corkscrew/node_modules/mocha
npm ERR! extraneous: [email protected] /home/ted/projects/vscode-f5/node_modules/f5-corkscrew/node_modules/nyc
npm ERR! extraneous: [email protected] /home/ted/projects/vscode-f5/node_modules/f5-corkscrew/node_modules/ts-node
npm ERR! extraneous: [email protected] /home/ted/projects/vscode-f5/node_modules/f5-corkscrew/node_modules/typescript
*****tried using yarn, but failed*****
ted@r2d2:~/projects/vscode-f5$ vsce package --yarn
Executing prepublish script 'yarn run vscode:prepublish'...
/bin/sh: 1: yarn: not found
ERROR yarn failed with exit code 127
*****removed ``"vscode:prepublish.old": "npm run compile",`` from package.json scripts, now yarn works*****
ted@r2d2:~/projects/vscode-f5$ vsce package --yarn
DONE Packaged: /home/ted/projects/vscode-f5/vscode-f5-3.0.0-beta-1.vsix (78 files, 5.39MB)
INFO
The latest version of vsce is 1.86.0 and you have 1.85.0.
Update it now: npm install -g vsce
ted@r2d2:~/projects/vscode-f5$