Open Finesse opened 4 years ago
This would be very helpful for create-react-app, where we occasionally get issues because people are running older versions. Telling them to run again with --ignore-existing
works to make sure it's not an actual bug, but --which
would let them know whether it's a global or local install they need to remove.
@Finesse I guess you are using NPX 10.12, not 6.12?
@karfau No:
Finesse ~ % npx --version
6.13.4
Finesse ~ % npm --version
6.13.4
Finesse ~ % node --version
v10.16.3
It looks as if npx just reports the version of npm when asked for it's version:
$ node --version
v10.18.0
$ npm --version
6.13.4
$ npx --version
6.13.4
but I traced it down to the version of libnpx
that is used:
$ cat /home/karfau/.nvm/versions/node/v10.18.0/lib/node_modules/npm/node_modules/libnpx/package.json
{
"_args": [
[
"libnpx@10.2.0",
"/Users/rebecca/code/npm"
]
],
"_from": "libnpx@10.2.0",
"_id": "libnpx@10.2.0",
"_inBundle": false,
"_integrity": "sha512-X28coei8/XRCt15cYStbLBph+KGhFra4VQhRBPuH/HHMkC5dxM8v24RVgUsvODKCrUZ0eTgiTqJp6zbl0sskQQ==",
"_location": "/libnpx",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "libnpx@10.2.0",
"name": "libnpx",
"escapedName": "libnpx",
"rawSpec": "10.2.0",
"saveSpec": null,
"fetchSpec": "10.2.0"
},
"_requiredBy": [
"/"
],
"_resolved": "https://registry.npmjs.org/libnpx/-/libnpx-10.2.0.tgz",
"_spec": "10.2.0",
"_where": "/Users/rebecca/code/npm",
"author": {
"name": "Kat Marchรกn",
"email": "kzm@sykosomatic.org"
},
"bugs": {
"url": "https://github.com/zkat/npx/issues"
},
"config": {
"nyc": {
"exclude": [
"node_modules/**",
"test/**"
]
}
},
"dependencies": {
"dotenv": "^5.0.1",
"npm-package-arg": "^6.0.0",
"rimraf": "^2.6.2",
"safe-buffer": "^5.1.0",
"update-notifier": "^2.3.0",
"which": "^1.3.0",
"y18n": "^4.0.0",
"yargs": "^11.0.0"
},
"description": "support library for npx -- an tool for executing npm-based packages.",
"devDependencies": {
"cross-env": "^5.1.3",
"json": "^9.0.6",
"marked-man": "^0.2.1",
"mkdirp": "^0.5.1",
"npm": "^5.7.1",
"nyc": "^11.4.1",
"require-inject": "^1.4.0",
"standard": "^11.0.0",
"standard-version": "^4.3.0",
"tacks": "^1.2.6",
"tap": "^11.1.2",
"weallbehave": "^1.2.0",
"weallcontribute": "^1.0.8"
},
"engines": {
"node": ">=4"
},
"files": [
"*.js",
"libnpx.1",
"locales"
],
"homepage": "https://github.com/zkat/npx#readme",
"keywords": [
"npm",
"npm exec",
"shell",
"scripts",
"npm bin",
"cli"
],
"license": "ISC",
"main": "index.js",
"man": [
"./libnpx.1"
],
"name": "libnpx",
"repository": {
"type": "git",
"url": "git+https://github.com/zkat/npx.git"
},
"scripts": {
"bin": "make bin",
"docs": "tail -n +2 README.md | marked-man --manual 'User Commands' --version \"$npm_package_name@$npm_package_version\" > $npm_package_name.1",
"postrelease": "npm publish && git push --follow-tags",
"prerelease": "npm t && npm run docs",
"pretest": "standard *.js test bin/*.js locales",
"publish-bin": "npm run bin && cd bin && npm publish",
"release": "standard-version -s",
"test": "cross-env NPX_UPDATE_LOCALE_FILES=true LC_ALL=en nyc --all -- tap -J test/*.js",
"update-coc": "weallbehave -o . && git add CODE_OF_CONDUCT.md && git commit -m 'docs(coc): updated CODE_OF_CONDUCT.md'",
"update-contrib": "weallcontribute -o . && git add CONTRIBUTING.md && git commit -m 'docs(contributing): updated CONTRIBUTING.md'"
},
"version": "10.2.0"
}
So I guess there is another issue to report regarding the --version
behavior...
Looks like the following command works:
# Replace `webpack` with any package name
npx which webpack
It considers PATH and node_modules
in parent directories. It can be the proper solution because NPX uses which as a dependency but the code is too tangled to find out whether it's 100% correct.
When you run, say,
npx webpack
in a terminal, NPX finds awebpack
package somewhere and runs it. How to identify the exact location of the binary that NXP runs? I'm looking for a tool like which in NPX.Maybe there is an option like this (warning, it's not a real code):
If there is no such feature, I request it.
Just in case, I use Node.js v10.16.3, NPM v6.12.0, NPX v6.12.0.