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

fix(dev): Specify "paths" in require.resolve() check #6371

Closed
wants to merge 4 commits into from
Closed

fix(dev): Specify "paths" in require.resolve() check #6371

wants to merge 4 commits into from

Conversation

TooTallNate
Copy link
Contributor

@TooTallNate TooTallNate commented May 10, 2023

require.resolve() by default will resolve module paths relative to the __filename of the code that is invoking it. This normally works, by coincidence, because usually @remix-run/dev is located within the project's node_modules directory.

However, we get a false positive when remix CLI is located outside of the project directory, for example when testing changes in a local checkout of this repo.

To fix, specify paths array to require.resolve() and explcitly specify the cwd to resolve from.

(Note: This is similar to #6181, but there appears to be duplicated code, and this file is missing the paths option).

Before

~/remix $ node ~/Code/remix-run/remix/packages/remix-dev/dist/cli.js build
Building Remix app in production mode...
The path "@remix-run/react" is imported in app/entry.server.tsx but "@remix-run/react" was not found in your node_modules. Did you forget to install it?
The path "react-dom/server" is imported in app/entry.server.tsx but "react-dom/server" was not found in your node_modules. Did you forget to install it?
Built in 190ms

(The modules are definitely installed, I promise)

After

~/remix $ node ~/Code/remix-run/remix/packages/remix-dev/dist/cli.js build
Building Remix app in production mode...
Built in 176ms

Closes: #5535

  • Docs
  • Tests

@changeset-bot
Copy link

changeset-bot bot commented May 10, 2023

🦋 Changeset detected

Latest commit: 5dc2ece

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 18 packages
Name Type
@remix-run/dev Patch
create-remix Patch
@remix-run/css-bundle Patch
remix Patch
@remix-run/architect Patch
@remix-run/cloudflare Patch
@remix-run/cloudflare-pages Patch
@remix-run/cloudflare-workers Patch
@remix-run/deno Patch
@remix-run/eslint-config Patch
@remix-run/express Patch
@remix-run/netlify Patch
@remix-run/node Patch
@remix-run/react Patch
@remix-run/serve Patch
@remix-run/server-runtime Patch
@remix-run/testing Patch
@remix-run/vercel Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@remix-cla-bot
Copy link
Contributor

remix-cla-bot bot commented May 15, 2023

Thank you for signing the Contributor License Agreement. Let's get this merged! 🥳

@TooTallNate TooTallNate closed this by deleting the head repository Jul 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants