Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] npx@7 silently errors with could not determine executable to run when trying to run a package bin script #2877

Open
brianjenkins94 opened this issue Mar 16, 2021 · 13 comments
Labels
Bug thing that needs fixing cmd:exec related to `npx` Priority 2 secondary priority issue Release 7.x work is associated with a specific npm 7 release

Comments

@brianjenkins94
Copy link

brianjenkins94 commented Mar 16, 2021

[!] The title may be misleading. I am using the version of `npx` that comes with `npm`,
    not the version you have to install via `npm install -g npx`.

Current Behavior:

$ npx brianjenkins94/kerplow
Need to install the following packages:
  github:brianjenkins94/kerplow
Ok to proceed? (y) y
$ 

Checking the logs, it looks like my script is failing with:

23 verbose stack Error: could not determine executable to run
23 verbose stack     at Exec.getBinFromManifest (/usr/local/lib/node_modules/npm/lib/exec.js:272:25)
23 verbose stack     at Exec._exec (/usr/local/lib/node_modules/npm/lib/exec.js:138:22)
24 verbose cwd /Users/bjenks/.npm/_cacache/tmp/git-clone-e17c5452

Surely that should have errored to the console, right?

Receiving nothing wasn't particularly helpful. Maybe instead it could tell me where it tried to run, what it tried to run and where it didn't find it?

Steps To Reproduce:

  1. In any environment where npm@7
  2. npx brianjenkins94/kerplow
  3. Nothing happens
Log
0 verbose cli [
0 verbose cli   '/usr/local/Cellar/node/15.11.0/bin/node',
0 verbose cli   '/usr/local/lib/node_modules/npm/bin/npm-cli.js',
0 verbose cli   'exec',
0 verbose cli   '--',
0 verbose cli   'install',
0 verbose cli   '--force',
0 verbose cli   '--cache=/Users/bjenks/.npm',
0 verbose cli   '--prefer-offline=false',
0 verbose cli   '--prefer-online=false',
0 verbose cli   '--offline=false',
0 verbose cli   '--no-progress',
0 verbose cli   '--no-save',
0 verbose cli   '--no-audit'
0 verbose cli ]
1 info using [email protected]
2 info using [email protected]
3 timing config:load:defaults Completed in 1ms
4 timing config:load:file:/usr/local/lib/node_modules/npm/npmrc Completed in 2ms
5 timing config:load:builtin Completed in 2ms
6 timing config:load:cli Completed in 1ms
7 timing config:load:env Completed in 0ms
8 timing config:load:file:/Users/bjenks/.npm/_cacache/tmp/git-clone-e17c5452/.npmrc Completed in 0ms
9 timing config:load:project Completed in 1ms
10 timing config:load:file:/Users/bjenks/.npmrc Completed in 0ms
11 timing config:load:user Completed in 0ms
12 timing config:load:file:/usr/local/etc/npmrc Completed in 1ms
13 timing config:load:global Completed in 1ms
14 timing config:load:cafile Completed in 0ms
15 timing config:load:validate Completed in 0ms
16 timing config:load:setUserAgent Completed in 1ms
17 timing config:load:setEnvs Completed in 0ms
18 timing config:load Completed in 7ms
19 verbose npm-session 47f8ff11c5fadcf7
20 timing npm:load Completed in 17ms
21 http fetch GET 304 https://registry.npmjs.org/install 1104ms (from cache)
22 timing command:exec Completed in 1120ms
23 verbose stack Error: could not determine executable to run
23 verbose stack     at Exec.getBinFromManifest (/usr/local/lib/node_modules/npm/lib/exec.js:272:25)
23 verbose stack     at Exec._exec (/usr/local/lib/node_modules/npm/lib/exec.js:138:22)
24 verbose cwd /Users/bjenks/.npm/_cacache/tmp/git-clone-e17c5452
25 verbose Darwin 19.6.0
26 verbose argv "/usr/local/Cellar/node/15.11.0/bin/node" "/usr/local/lib/node_modules/npm/bin/npm-cli.js" "exec" "--" "install" "--force" "--cache=/Users/bjenks/.npm" "--prefer-offline=false" "--prefer-online=false" "--offline=false" "--no-progress" "--no-save" "--no-audit"
27 verbose node v15.11.0
28 verbose npm  v7.6.3
29 error could not determine executable to run
30 verbose exit 1

Expected Behavior:

For npm@6 I get my example output (or it runs npm init if there's no package.json in the current directory).

Is there a migration guide I missed or something? Is this change in behavior expected?

Looks like this is what I missed 🤔: https://blog.npmjs.org/post/626173315965468672/npm-v7-series-beta-release-and-semver-major

Environment:

  • Darwin 19.6.0
  • node v15.11.0
  • npm v7.6.3
@brianjenkins94 brianjenkins94 added Bug thing that needs fixing Needs Triage needs review for next steps Release 7.x work is associated with a specific npm 7 release labels Mar 16, 2021
@wraithgar
Copy link
Member

I believe this was fixed in v7.7.0, the prompt code wasn't being called properly but it should be now.

@wraithgar wraithgar removed the Needs Triage needs review for next steps label Mar 24, 2021
@wraithgar wraithgar self-assigned this Mar 24, 2021
@brianjenkins94
Copy link
Author

Just tried [email protected] on Windows; it doesn't seem fixed. I'll try my Mac.

@wraithgar wraithgar added the Priority 2 secondary priority issue label Mar 24, 2021
@wraithgar wraithgar removed their assignment Mar 24, 2021
@brianjenkins94
Copy link
Author

Same results from [email protected] on my Mac.

@brianjenkins94
Copy link
Author

29 verbose stack Error: could not determine executable to run
29 verbose stack     at getBinFromManifest (/usr/local/lib/node_modules/npm/node_modules/libnpmexec/lib/get-bin-from-manifest.js:15:23)
29 verbose stack     at exec (/usr/local/lib/node_modules/npm/node_modules/libnpmexec/lib/index.js:112:15)
30 verbose pkgid [email protected]
31 verbose cwd /Users/bjenks/.npm/tmp/git-clone-fcdbb210
32 verbose Darwin 19.6.0
33 verbose argv "/usr/local/Cellar/node/16.1.0/bin/node" "/usr/local/lib/node_modules/npm/bin/npm-cli.js" "exec" "--" "install" "--force" "--cache=/Users/bjenks" "--prefer-offline=false" "--prefer-online=false" "--offline=false" "--no-progress" "--no-save" "--no-audit"
34 verbose node v16.1.0
35 verbose npm  v7.13.0
36 error could not determine executable to run
37 verbose exit 1

Same error, new stack trace.

@brianjenkins94
Copy link
Author

BountySource

@brianjenkins94 brianjenkins94 changed the title [BUG] npx@7 silently errors when trying to run a package bin script where npx@6 had worked [BUG] npx@7 silently errors with could not determine executable to run when trying to run a package bin script Jun 26, 2021
@brianjenkins94
Copy link
Author

I don't know how this makes any sense, but it appears to have something to do with having a script named build.

@lukekarrys
Copy link
Contributor

I don't know how this makes any sense, but it appears to have something to do with having a script named build.

This is interesting because someone else reported a different issue that was fixed by renaming a build script. #3692 (comment)

@fritzy fritzy added the cmd:exec related to `npx` label Jul 25, 2022
@wraithgar
Copy link
Member

Can you test this in [email protected]? npm exec had a lot of bugfixes in that release, including properly installing git repos.

@wraithgar
Copy link
Member

This looks like it was fixed.

~/D/n/s/empty $ npx wraithgar/gar-create-test
Need to install the following packages:
  github:wraithgar/gar-create-test
Ok to proceed? (y) 
Gar's test create script version 2.0.3

@brianjenkins94
Copy link
Author

brianjenkins94 commented Aug 3, 2022

Sorry, I spoke to soon, this doesn't appear to be fixed.

% node -v
v18.6.0
% npm -v
8.16.0
%  npx brianjenkins94/kerplow
Need to install the following packages:
  github:brianjenkins94/kerplow
Ok to proceed? (y) y
% echo $?
1

Kindly reopen.

@wraithgar I suspect if you add a script named "build" to your package.json, you'll see the same.

@brianjenkins94
Copy link
Author

@wraithgar Kindly reopen.

@ljharb ljharb reopened this Aug 4, 2022
@ilyaigpetrov
Copy link

I have a similar problem after running npm start on one of my projects (sorry, I haven't minimized the code to the minimum reproduction sample yet):

38 verbose stack Error: could not determine executable to run
38 verbose stack     at getBinFromManifest (/usr/lib/node_modules/npm/node_modules/libnpmexec/lib/get-bin-from-manifest.js:17:23)
38 verbose stack     at exec (/usr/lib/node_modules/npm/node_modules/libnpmexec/lib/index.js:173:15)
38 verbose stack     at async module.exports (/usr/lib/node_modules/npm/lib/cli.js:78:5)
39 verbose pkgid gulp@4.0.2

If I add console.log just before this error is thrown in /usr/lib/node_modules/npm/node_modules/libnpmexec/lib/get-bin-from-manifest.js:

const getBinFromManifest = (mani) => {
  // if we have a bin matching (unscoped portion of) packagename, use that
  // otherwise if there's 1 bin or all bin value is the same (alias), use
  // that, otherwise fail
  const bin = mani.bin || {}
  if (new Set(Object.values(bin)).size === 1) {
    return Object.keys(bin)[0]
  }

  // XXX probably a util to parse this better?
  const name = mani.name.replace(/^@[^/]+\//, '')
  if (bin[name]) {
    return name
  }

  // XXX need better error message
  console.log('ERR WITH MANIFEST:', mani) // ADDED BY ME
  throw Object.assign(new Error('could not determine executable to run'), {
    pkgid: mani._id,
  })
}

module.exports = getBinFromManifest

Then I get in output:

ERR WITH MANIFEST: {
  version: '4.0.2',
  resolved: 'https://registry.npmjs.org/gulp/-/gulp-4.0.2.tgz',
  integrity: 'sha512-dvEs27SCZt2ibF29xYgmnwwCYZxdxhQ/+LFWlbAW8y7jt68L/65402Lz3+CKy0Ov4rOs+NERmDq7YlZaDqUIfA==',
  dependencies: {
    'glob-watcher': '^5.0.3',
    'gulp-cli': '^2.2.0',
    undertaker: '^1.2.1',
    'vinyl-fs': '^3.0.0'
  },
  name: 'gulp',
  _id: '[email protected]'
}
npm@8.19.1
node@v18.8.0
Full log
0 verbose cli /usr/bin/node /usr/lib/node_modules/npm/bin/npm-cli.js
1 info using npm@8.19.1
2 info using node@v18.8.0
3 timing npm:load:whichnode Completed in 0ms
4 timing config:load:defaults Completed in 2ms
5 timing config:load:file:/usr/lib/node_modules/npm/npmrc Completed in 1ms
6 timing config:load:builtin Completed in 1ms
7 timing config:load:cli Completed in 2ms
8 timing config:load:env Completed in 1ms
9 timing config:load:file:/home/ilyaigpetrov/Projects/runet-censorship-bypass/extensions/chromium/runet-censorship-bypass/.npmrc Completed in 1ms
10 timing config:load:project Completed in 15ms
11 timing config:load:file:/home/ilyaigpetrov/.npmrc Completed in 0ms
12 timing config:load:user Completed in 0ms
13 timing config:load:file:/usr/etc/npmrc Completed in 0ms
14 timing config:load:global Completed in 0ms
15 timing config:load:validate Completed in 1ms
16 timing config:load:credentials Completed in 1ms
17 timing config:load:setEnvs Completed in 1ms
18 timing config:load Completed in 25ms
19 timing npm:load:configload Completed in 25ms
20 timing npm:load:mkdirpcache Completed in 1ms
21 timing npm:load:mkdirplogs Completed in 0ms
22 verbose title npm exec gulp -- buildAll
23 verbose argv "exec" "--" "gulp" "--" "buildAll"
24 timing npm:load:setTitle Completed in 2ms
25 timing config:load:flatten Completed in 4ms
26 timing npm:load:display Completed in 6ms
27 verbose logfile logs-max:10 dir:/home/ilyaigpetrov/.npm/_logs
28 verbose logfile /home/ilyaigpetrov/.npm/_logs/2022-09-05T16_25_42_196Z-debug-0.log
29 timing npm:load:logFile Completed in 7ms
30 timing npm:load:timers Completed in 0ms
31 timing npm:load:configScope Completed in 0ms
32 timing npm:load Completed in 43ms
33 silly logfile start cleaning logs, removing 1 files
34 silly logfile done cleaning log files
35 timing arborist:ctor Completed in 1ms
36 timing arborist:ctor Completed in 0ms
37 timing command:exec Completed in 564ms
38 verbose stack Error: could not determine executable to run
38 verbose stack     at getBinFromManifest (/usr/lib/node_modules/npm/node_modules/libnpmexec/lib/get-bin-from-manifest.js:17:23)
38 verbose stack     at exec (/usr/lib/node_modules/npm/node_modules/libnpmexec/lib/index.js:173:15)
38 verbose stack     at async module.exports (/usr/lib/node_modules/npm/lib/cli.js:78:5)
39 verbose pkgid gulp@4.0.2
40 verbose cwd /home/ilyaigpetrov/Projects/runet-censorship-bypass/extensions/chromium/runet-censorship-bypass
41 verbose Linux 5.15.0-46-generic
42 verbose node v18.8.0
43 verbose npm  v8.19.1
44 error could not determine executable to run
45 verbose exit 1
46 timing npm Completed in 726ms
47 verbose code 1
48 error A complete log of this run can be found in:
48 error     /home/ilyaigpetrov/.npm/_logs/2022-09-05T16_25_42_196Z-debug-0.log

@ilyaigpetrov
Copy link

My problem was fixed after installing gulp-cli:

sudo npm install --global gulp-cli

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing cmd:exec related to `npx` Priority 2 secondary priority issue Release 7.x work is associated with a specific npm 7 release
Projects
None yet
Development

No branches or pull requests

6 participants