cli
cli copied to clipboard
[FEATURE] npx should show execution path (in --verbose mode)
Is there an existing issue for this?
- [X] I have searched the existing issues
This issue exists in the latest npm version
- [X] I am using the latest npm
Current Behavior
When you type a npx <other command>
. it is runs but you don't know how command runs.
For example:
npx tsc
But you type bad:
npx tsm
And maybe (in my case yes) you don't know what is tsm.
Expected Behavior
Maybe with --verbose
npx could shows the execution path of binary or script called.
You type and the output could be something as:
$ npx --verbose tsc
[LOG] Level verbose
[LOG] Execute ./node_modules/typescript/bin/tsc
[LOG] Other useful things....
[LOG]....
Steps To Reproduce
No response
Environment
No response
npx supports a loglevel flag, which can be set to one of: silent, error, warn, notice, http, timing, info, verbose or silly.
npx supports a loglevel flag, which can be set to one of: silent, error, warn, notice, http, timing, info, verbose or silly.
EDIT: sorry the old message was on old npm version I use nvm. But with the latest verion v16.13.0 is:
$ npx --loglevel verbose tsc
npm verb cli [
npm verb cli '/home/miguel/.nvm/versions/node/v12.20.0/bin/node',
npm verb cli '/home/miguel/.nvm/versions/node/v12.20.0/lib/node_modules/npm/bin/npm-cli.js',
npm verb cli 'exec',
npm verb cli '--loglevel',
npm verb cli 'verbose',
npm verb cli '--',
npm verb cli 'tsc'
npm verb cli ]
npm info using [email protected]
npm info using [email protected]
npm timing npm:load:whichnode Completed in 0ms
npm timing config:load:defaults Completed in 1ms
npm timing config:load:file:/home/panacea/.nvm/versions/node/v12.20.0/lib/node_modules/npm/npmrc Completed in 1ms
npm timing config:load:builtin Completed in 1ms
npm timing config:load:cli Completed in 2ms
npm timing config:load:env Completed in 0ms
npm timing config:load:file:/tmp/caca/.npmrc Completed in 0ms
npm timing config:load:project Completed in 0ms
npm timing config:load:file:/home/panacea/.npmrc Completed in 0ms
npm timing config:load:user Completed in 1ms
npm timing config:load:file:/home/panacea/.nvm/versions/node/v12.20.0/etc/npmrc Completed in 0ms
npm timing config:load:global Completed in 0ms
npm timing config:load:validate Completed in 0ms
npm timing config:load:credentials Completed in 1ms
npm timing config:load:setEnvs Completed in 0ms
npm timing config:load Completed in 6ms
npm timing npm:load:configload Completed in 6ms
npm timing npm:load:setTitle Completed in 0ms
npm timing npm:load:setupLog Completed in 1ms
npm timing config:load:flatten Completed in 1ms
npm timing npm:load:cleanupLog Completed in 2ms
npm timing npm:load:configScope Completed in 0ms
npm timing npm:load:projectScope Completed in 1ms
npm timing npm:load Completed in 14ms
Version 4.4.4
tsc: The TypeScript Compiler - Version 4.4.4
TS
COMMON COMMANDS
tsc
Compiles the current project (tsconfig.json in the working directory.)
tsc app.ts util.ts
Ignoring tsconfig.json, compiles the specified files with default compiler options.
tsc -b
Build a composite project in the working directory.
tsc --init
Creates a tsconfig.json with the recommended settings in the working directory.
tsc -p ./path/to/tsconfig.json
Compiles the TypeScript project located at the specified path.
tsc --help --all
An expanded version of this information, showing all possible compiler options
tsc --noEmit
tsc --target esnext
Compiles the current project, with additional settings.
COMMAND LINE FLAGS
--help, -h Print this message.
--watch, -w Watch input files.
--all Show all compiler options.
--version, -v Print the compiler's version.
--init Initializes a TypeScript project and creates a tsconfig.json file.
--project, -p Compile the project given the path to its configuration file, or to a folder with a 'tsconfig.json'.
--build, -b Build one or more projects and their dependencies, if out of date
--showConfig Print the final configuration instead of building.
COMMON COMPILER OPTIONS
--pretty Enable color and formatting in TypeScript's output to make compiler errors easier to read
type: boolean
default: true
--target, -t Set the JavaScript language version for emitted JavaScript and include compatible library declarations.
one of: es3, es5, es6, es2015, es2016, es2017, es2018, es2019, es2020, es2021, esnext
default: ES3
--module, -m Specify what module code is generated.
one of: none, commonjs, amd, system, umd, es6, es2015, es2020, esnext
--lib Specify a set of bundled library declaration files that describe the target runtime environment.
one or more: es5, es6, es2015, es7, es2016, es2017, es2018, es2019, es2020, es2021, esnext, dom, dom.iterable, webworker, webworker.importscripts, webworker.iterable, scripthost, es2015.core, es2015.collection, es2015.generato r, es2015.iterable, es2015.promise, es2015.proxy, es2015.reflect, es2015.symbol, es2015.symbol.wellknown, es2016.array.include, es2017.object, es2017.sharedmemory, es2017.string, es2017.intl, es2017.typedarrays, e s2018.asyncgenerator, es2018.asynciterable, es2018.intl, es2018.promise, es2018.regexp, es2019.array, es2019.object, es2019.string, es2019.symbol, es2020.bigint, es2020.promise, es2020.sharedmemory, es2020.string, es2020.symbol.wellknown, es2020.intl, es2021.promise, es2021.string, es2021.weakref, esnext.array, esnext.symbol, esnext.asynciterable, esnext.intl, esnext.bigint, esnext.string, esnext.promise, esnext.weakref
--allowJs Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files.
type: boolean
default: false
--checkJs Enable error reporting in type-checked JavaScript files.
type: boolean
default: false
--jsx Specify what JSX code is generated.
one of: preserve, react-native, react, react-jsx, react-jsxdev
default: undefined
--declaration, -d Generate .d.ts files from TypeScript and JavaScript files in your project.
type: boolean
default: `false`, unless `composite` is set
--declarationMap Create sourcemaps for d.ts files.
type: boolean
default: false
--emitDeclarationOnly Only output d.ts files and not JavaScript files.
type: boolean
default: false
--sourceMap Create source map files for emitted JavaScript files.
type: boolean
default: false
--outFile Specify a file that bundles all outputs into one JavaScript file. If `declaration` is true, also designates a file that bundles all .d.ts output.
--outDir Specify an output folder for all emitted files.
--removeComments Disable emitting comments.
type: boolean
default: false
--noEmit Disable emitting files from a compilation.
type: boolean
default: false
--strict Enable all strict type-checking options.
type: boolean
default: false
--types Specify type package names to be included without being referenced in a source file.
--esModuleInterop Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility.
type: boolean
default: false
You can learn about all of the compiler options at https://aka.ms/tsconfig-reference
npm timing command:exec Completed in 166ms
npm verb exit 1
npm timing npm Completed in 334ms
npm verb code 1
And the log does not show the execution path.
Thanks @mbtts-elsevier , I have changed the title for other more exact.
I found a trick with GNU/Linux to get the path, it is with strace and some greps:
$ strace -f npx tsc 2>&1 | grep "/tmp" | grep "tsc"
[pid 40548] statx(AT_FDCWD, "/tmp/caca/node_modules/.bin/tsc", AT_STATX_SYNC_AS_STAT, STATX_ALL, <unfinished ...>
[pid 40549] execve("/tmp/caca/node_modules/.bin/sh", ["sh", "-c", "tsc"], 0x3fae3a0 /* 104 vars */) = -1 ENOENT (No existe el archivo o el directorio)
[pid 40549] execve("/tmp/node_modules/.bin/sh", ["sh", "-c", "tsc"], 0x3fae3a0 /* 104 vars */) = -1 ENOENT (No existe el archivo o el directorio)
[pid 40549] execve("/tmp/caca/node_modules/.bin/sh", ["sh", "-c", "tsc"], 0x3fae3a0 /* 104 vars */) = -1 ENOENT (No existe el archivo o el directorio)
[pid 40549] stat("/tmp/caca/node_modules/.bin/tsc", <unfinished ...>
[pid 40550] execve("/tmp/caca/node_modules/.bin/tsc", ["tsc"], 0x55f97cde27e8 /* 104 vars */ <unfinished ...>
[pid 40550] execve("/tmp/caca/node_modules/.bin/node", ["node", "/tmp/caca/node_modules/.bin/tsc"], 0x7fff31783038 /* 104 vars */) = -1 ENOENT (No existe el archivo o el directorio)
[pid 40550] execve("/tmp/node_modules/.bin/node", ["node", "/tmp/caca/node_modules/.bin/tsc"], 0x7fff31783038 /* 104 vars */) = -1 ENOENT (No existe el archivo o el directorio)
[pid 40550] execve("/node_modules/.bin/node", ["node", "/tmp/caca/node_modules/.bin/tsc"], 0x7fff31783038 /* 104 vars */) = -1 ENOENT (No existe el archivo o el directorio)
[pid 40550] execve("/home/panacea/.nvm/versions/node/v12.20.0/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin/node", ["node", "/tmp/caca/node_modules/.bin/tsc"], 0x7fff31783038 /* 104 vars */) = -1 ENOENT (No existe el archivo o el directorio)
[pid 40550] execve("/tmp/caca/node_modules/.bin/node", ["node", "/tmp/caca/node_modules/.bin/tsc"], 0x7fff31783038 /* 104 vars */) = -1 ENOENT (No existe el archivo o el directorio)
[pid 40550] execve("/home/panacea/.local/bin/node", ["node", "/tmp/caca/node_modules/.bin/tsc"], 0x7fff31783038 /* 104 vars */) = -1 ENOENT (No existe el archivo o el directorio)
[pid 40550] execve("/home/panacea/.nvm/versions/node/v12.20.0/bin/node", ["node", "/tmp/caca/node_modules/.bin/tsc"], 0x7fff31783038 /* 104 vars */ <unfinished ...>
[pid 40550] statx(AT_FDCWD, "/tmp/caca/node_modules/.bin/tsc", AT_STATX_SYNC_AS_STAT, STATX_ALL, {stx_mask=STATX_ALL, stx_attributes=0, stx_mode=S_IFREG|0775, stx_size=45, ...}) = 0
[pid 40550] statx(AT_FDCWD, "/tmp/caca/node_modules/.bin/tsc", AT_STATX_SYNC_AS_STAT|AT_SYMLINK_NOFOLLOW, STATX_ALL, {stx_mask=STATX_ALL, stx_attributes=0, stx_mode=S_IFLNK|0777, stx_size=21, ...}) = 0
[pid 40550] statx(AT_FDCWD, "/tmp/caca/node_modules/.bin/tsc", AT_STATX_SYNC_AS_STAT, STATX_ALL, {stx_mask=STATX_ALL, stx_attributes=0, stx_mode=S_IFREG|0775, stx_size=45, ...}) = 0
[pid 40550] readlink("/tmp/caca/node_modules/.bin/tsc", "../typescript/bin/tsc", 4096) = 21
[pid 40550] statx(AT_FDCWD, "/tmp/caca/node_modules/typescript/bin/tsc", AT_STATX_SYNC_AS_STAT|AT_SYMLINK_NOFOLLOW, STATX_ALL, {stx_mask=STATX_ALL, stx_attributes=0, stx_mode=S_IFREG|0775, stx_size=45, ...}) = 0
[pid 40550] openat(AT_FDCWD, "/tmp/caca/node_modules/typescript/bin/tsc", O_RDONLY|O_CLOEXEC) = 17
[pid 40550] statx(AT_FDCWD, "/tmp/caca/node_modules/typescript/lib/tsc.js", AT_STATX_SYNC_AS_STAT, STATX_ALL, {stx_mask=STATX_ALL, stx_attributes=0, stx_mode=S_IFREG|0664, stx_size=5627651, ...}) = 0
[pid 40550] statx(AT_FDCWD, "/tmp/caca/node_modules/typescript/lib/tsc.js", AT_STATX_SYNC_AS_STAT|AT_SYMLINK_NOFOLLOW, STATX_ALL, {stx_mask=STATX_ALL, stx_attributes=0, stx_mode=S_IFREG|0664, stx_size=5627651, ...}) = 0
[pid 40550] openat(AT_FDCWD, "/tmp/caca/node_modules/typescript/lib/tsc.js", O_RDONLY|O_CLOEXEC) = 17
[pid 40550] statx(AT_FDCWD, "/tmp/caca/tsconfig.json", AT_STATX_SYNC_AS_STAT, STATX_ALL, 0x7ffc7bbe59e0) = -1 ENOENT (No existe el archivo o el directorio)
[pid 40550] statx(AT_FDCWD, "/tmp/tsconfig.json", AT_STATX_SYNC_AS_STAT, STATX_ALL, 0x7ffc7bbe59e0) = -1 ENOENT (No existe el archivo o el directorio)
But it is good thing showing the path with --verbose mode.
+1 to this; I'd like to know where npx
gets the binary it runs. Global installations (I don't want that)? Root node_modules
? Subpackage node_modules
? Path resolution is already complex enough that we need an npm which