getappmap / appmap-agent-js

This project is deprecated. Please use https://github.com/getappmap/appmap-node/ to record Node.js applications.
Other
28 stars 8 forks source link

Local resolution of npx with yarn #167

Open lachrist opened 1 year ago

lachrist commented 1 year ago
yarn add @appland/appmap-agent-js
cd packages/sequence-diagram
npx @appland/appmap-agent-js -- npx jest
/Users/soft/Desktop/workspace/appmap-js/node_modules/npm/lib/utils/explain-dep.js:1
const chalk = require('chalk')
              ^

Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/soft/Desktop/workspace/appmap-js/node_modules/npm/node_modules/chalk/source/index.js from /Users/soft/Desktop/workspace/appmap-js/node_modules/npm/lib/utils/explain-dep.js not supported.

I did some digging and with the agent, the command npx jest resolves to:

/Users/soft/.nvm/versions/node/v18.12.1/bin/node /Users/soft/Desktop/workspace/appmap-js/node_modules/.bin/npx jest

And sure enough this causes the same error without the involvement of the agent:

node ../../node_modules/.bin/npx jest

Whereas this works fins:

node /Users/soft/.nvm/versions/node/v18.12.1/bin/npx jest

So the problem is that the agent makes npx jest resolve to the npx installed in the project and not the globally installed npx.