vercel / pkg

Package your Node.js project into an executable
https://npmjs.com/pkg
MIT License
24.33k stars 1.02k forks source link

test script crashes with bad invocation of npx #1921

Closed rotu closed 10 months ago

rotu commented 1 year ago

What version of pkg are you using?

5.8.1

What version of Node.js are you using?

20.0.0

What operating system are you using?

macOS

What CPU architecture are you using?

Apple M1

What Node versions, OSs and CPU architectures are you building for?

default

Describe the Bug

npm run test fails, as the code in pkg/test/test-10-pnpm/main.js attempts to call npm from the wrong fully qualified path. The code falsely assumes that the node and the npx executables exist as sibling files in the same directory.

Note that, as installed by homebrew, the following executable and symlinks exist:

npm run test

> pkg@5.8.1 test
> npm run build && npm run test:18 && npm run test:16 && npm run test:14 && npm run test:host

> pkg@5.8.1 build
> npm run clean && tsc

> pkg@5.8.1 clean
> rimraf lib-es5

> pkg@5.8.1 test:18
> node test/test.js node18 no-npm

Debugger listening on ws://127.0.0.1:59850/a219d318-6cf6-426f-98fa-049fe3357707
For help, see: https://nodejs.org/en/docs/inspector
Debugger attached.

*************************************
node18 no-npm
*************************************

Debugger listening on ws://127.0.0.1:59852/f2f10443-fe9d-43b9-8dd5-e8906e72e2e4
For help, see: https://nodejs.org/en/docs/inspector
Debugger attached.
target =  node18
> /opt/homebrew/Cellar/node/20.0.0/bin/npx pnpm install
Waiting for the debugger to disconnect...
/Users/dan/Source/pkg/test/utils.js:89
    throw child.error;
    ^

Error: spawnSync /opt/homebrew/Cellar/node/20.0.0/bin/npx ENOENT
    at Object.spawnSync (node:internal/child_process:1117:20)
    at spawnSync (node:child_process:871:24)
    at module.exports.spawn.sync (/Users/dan/Source/pkg/test/utils.js:74:17)
    at Object.<anonymous> (/Users/dan/Source/pkg/test/test-10-pnpm/main.js:27:29)
    at Module._compile (node:internal/modules/cjs/loader:1267:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1321:10)
    at Module.load (node:internal/modules/cjs/loader:1125:32)
    at Module._load (node:internal/modules/cjs/loader:965:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12)
    at node:internal/main/run_main_module:23:47 {
  errno: -2,
  code: 'ENOENT',
  syscall: 'spawnSync /opt/homebrew/Cellar/node/20.0.0/bin/npx',
  path: '/opt/homebrew/Cellar/node/20.0.0/bin/npx',
  spawnargs: [ 'pnpm', 'install' ]
}

Expected Behavior

npm run test should succeed.

To Reproduce

npm run test

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 90 days with no activity. Remove the stale label or comment or this will be closed in 5 days. To ignore this issue entirely you can add the no-stale label

rotu commented 1 year ago

.

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 90 days with no activity. Remove the stale label or comment or this will be closed in 5 days. To ignore this issue entirely you can add the no-stale label

rotu commented 1 year ago

.