Vscode-vsce: Have NPM as a runtime dependency

Created on 19 Mar 2018  路  20Comments  路  Source: microsoft/vscode-vsce

I'm trying to package my extension based on the lsp-sample. I run vsce package in the client directory and it says:

$ vsce package
Executing prepublish script 'npm run vscode:prepublish'...

> [email protected] vscode:prepublish /Volumes/Seagate/Users2/ribrdb/Developer/vscode-extension-samples-master/lsp-sample/client
> ../node_modules/.bin/tsc -p ./

Error: Command failed: npm list --production --parseable --depth=99999
npm ERR! missing: block-stream@https://registry.npmjs.org/block-stream/-/block-stream-0.0.9.tgz, required by [email protected]
npm ERR! missing: inherits@https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz, required by block-stream@https://registry.npmjs.org/block-stream/-/block-stream-0.0.9.tgz
feature-request

Most helpful comment

Ahh... thanks

$ vsce package --yarn
Executing prepublish script 'npm run vscode:prepublish'...

The console output still using npm, but it works.

All 20 comments

If you run npm list --production --parseable --depth=99999, what happens?

I am having the same problem. When I run that command I get:

$ 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]
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]

Did you run npm install?

I had the same issue, apparently it's caused by npm/npm#19393. I was able to work around it by downgrading npm: npm install -g [email protected]

Another workaround mentioned in npm/npm#19393 that worked for me (with npm version 5.8.0): rm -Rf node_modules/ package-lock.json ; npm install --no-optional

Good to know!

After updating the dependencies for my extension, the npm install --no-optional workaround didn't work for me anymore. So now the only workaround that works for me is downgrading npm.
The npm authors are showing zero interest in this bug: lots of users are confirming this problem, but after almost half a year there is not a single response from them.
Maybe you should consider finding a workaround for this that can be built into vsce: more and more extension authors are going to get hit by this (because more and more packages make use of optional dependencies) and having to tell extension authors that they can't publish their extensions with a current version of npm seems... weird.

@hbenl Thanks, that's good to know. Maybe VSCE should depend on a specific NPM version?

@joaomoreno I'm afraid that wouldn't solve the problem: if an extension developer has a newer version of npm installed globally and uses that to install the dependencies of his extension then every version of npm will fail on npm ls in that folder. At least that's the experience I had when downgrading to [email protected]: npm ls (and hence vsce publish) still failed until I reinstalled my dependencies with the downgraded npm.

Sorry, that was a confusing comment. I meant: let's add NPM as a node dependency to VSCE. That way we can lock it and use it as a library as well.

Actually I think I had understood you correctly, but apparently _my_ comment wasn't clear enough :)
I guess I should explain in more detail what I _think_ is happening: [email protected] made a slight change to how npm install works (see the first feature mentioned here). Due to a bug described in detail in npm/npm#19428, npm ls can't make sense of the result of npm install.

So it doesn't matter what version of npm you use to run npm ls, they will all fail if a recent version of npm was used to do npm install. If you add npm as a node dependency to vsce and use that to do npm ls, nothing changes. You'd need to control the version of npm that is used to do npm install, i.e. the version of npm that the user has installed globally.

So what can be done? First of all, you could try to detect if npm ls fails due to this issue and tell the user what he can do (downgrade npm and reinstall his dependencies with the downgraded version) and link to this issue. You could also add "npm" : "<5.6.0" to the engines field in the package.json of vsce - that should produce a warning message if a user runs npm install with a new version of npm in a project that lists vsce as a dependency.

Apart from that, I don't see an easy solution: vsce needs a working implementation of npm ls. Since no version of npm seems to have a fully functional implementation, maybe you could find one elsewhere? I was thinking about yarn list, but that doesn't have the --production flag, which I guess is crucial for vsce.
If no such implementation can be found, someone would have to create one or fix the implementation in npm. But that seems like a lot of work for an issue that has not hit that many users - so far.

It happen to me when using yarn. Is it possible to give options for using yarn instead of npm?

@uudashr --yarn

Ahh... thanks

$ vsce package --yarn
Executing prepublish script 'npm run vscode:prepublish'...

The console output still using npm, but it works.

It works for me to run:

vsce publish --yarn

vsce package --yarn Solved my problem

It solved my problem as well and sorry for references. They weren't intentional.

Hello! At first, when I packaged the vscode plug-in, I reported an error as follows

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

However, according to the feedback from GitHub, it was the NPM version problem. I said that NPM version 5.5.1 was needed. However, after the version was changed here, the following errors appeared again

report errors

ERROR Command failed: npm list --production --parseable --depth=99999 --loglevel=error
npm ERR! cb.apply is not a function

I found that the error is not only related to the NPM version, but also to the location of the dependent package and the dev dependent package

I found that the error is not only related to the NPM version, but also to the location of the dependent package and the dev dependent package

What was the relation and how did you fix it? I'm having the same issue and I specifically need to use npm as my package manager rather than yarn

Was this page helpful?
0 / 5 - 0 ratings

Related issues

brandoncc picture brandoncc  路  6Comments

shanalikhan picture shanalikhan  路  6Comments

felixfbecker picture felixfbecker  路  6Comments

vazexqi picture vazexqi  路  4Comments

SamVerschueren picture SamVerschueren  路  5Comments