Take NODE_PATH into account when resolving modules#16274
Merged
Conversation
RobinMalfait
approved these changes
Feb 5, 2025
RobinMalfait
left a comment
Member
There was a problem hiding this comment.
Sweet! Can you add a changelog entry?
Contributor
Author
Yes sir this is indeed part of my set of abilities. |
4 tasks
Contributor
|
It looks like this does not work in the standalone CLI, is that expected? vs |
SteffenDE
added a commit
to SteffenDE/tailwindcss
that referenced
this pull request
Jan 29, 2026
also allows to pass a path with separator References tailwindlabs#19391. References tailwindlabs#16274.
RobinMalfait
added a commit
that referenced
this pull request
Apr 17, 2026
References #19391. References #16274. Right now, when using the standalone build of the TailwindCSS CLI, you cannot use a custom `NODE_PATH`, but you can when using it via Node.js directly. A custom NODE_PATH allows you to resolve imports from multiple locations. For example, in [Phoenix LiveView](https://github.com/phoenixframework/phoenix_live_view/), we have a feature where you can write scripts in templates that we extract at compile time to a custom folder and users can import those in their application bundle by saying ```javascript import { hooks as colocatedHooks } from "phoenix-colocated/my_app" ``` where the "phoenix-colocated" folder lives in a different location than the usual `node_modules` folder. This works fine with the default esbuild setup, as it respects `NODE_PATH`, so we can pass it a custom location. We want to also support colocating CSS in templates soon, but the same approach doesn't work with the standalone Tailwind CLI we ship with default Phoenix projects. It works when running Tailwind through Node.js, but we don't want to tell users they need to install it, just to use the feature. This patch changes the lookup logic for the standalone CLI to also account for `NODE_PATH`. Note that you can pass multiple paths, that are split according the the OS PATH separator. --------- Co-authored-by: Robin Malfait <malfait.robin@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #15847
This PR changes the node specific resolver config to takes the eventual
NODE_PATHenv into account.Test plan
See #15847