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

require.resolve unable to find node module #8974

Closed
roninjin10 opened this issue Feb 18, 2024 · 3 comments · Fixed by #14227
Closed

require.resolve unable to find node module #8974

roninjin10 opened this issue Feb 18, 2024 · 3 comments · Fixed by #14227
Assignees
Labels
bug Something isn't working node.js Compatibility with Node.js APIs

Comments

@roninjin10
Copy link

roninjin10 commented Feb 18, 2024

What version of Bun is running?

1.0.27+c34bbb2e3

What platform is your computer?

Darwin 23.2.0 arm64 arm

What steps can reproduce the bug?

  1. bun init
  2. bun install @tevm/contract
  3. Add following script and run it with bun and node. Node will return the path while bun will fail to return the correct path
import { createRequire } from 'module';

const require = createRequire(
  `${process.cwd()}/`
);

console.log(
  require.resolve('@tevm/contract')
)

What is the expected behavior?

This should be able to resolve a node module relative to process.cwd() like node does

What do you see instead?

Node is able to resolve this while bun fails

Additional information

telegram-cloud-photo-size-1-5084681159350266970-y

@roninjin10 roninjin10 added the bug Something isn't working label Feb 18, 2024
@Electroid Electroid added the node.js Compatibility with Node.js APIs label Feb 18, 2024
@jdalton jdalton self-assigned this Feb 23, 2024
@jdalton
Copy link
Contributor

jdalton commented Feb 23, 2024

console.log(Module._resolveFilename('@tevm/contract', null, false)); // works in bun

@elix1er
Copy link

elix1er commented Jun 19, 2024

bump

@henrikvilhelmberglund
Copy link

Also an issue when using TutorialKit. Above workaround did not work for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working node.js Compatibility with Node.js APIs
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants