Skip to content

Commit 3f8e764

Browse files
Take NODE_PATH into account when resolving modules (#16274)
Fixes #15847 This PR changes the node specific resolver config to takes the eventual `NODE_PATH` env into account. ## Test plan See #15847 <img width="1273" alt="Screenshot 2025-02-05 at 12 58 20" src="https://github.com/user-attachments/assets/8e1b99d1-608d-437a-a7b2-212feb153da5" />
1 parent 82d486a commit 3f8e764

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515
- Fix missing `@keyframes` definition ([#16237](https://github.com/tailwindlabs/tailwindcss/pull/16237))
1616
- Vite: Skip parsing stylesheets with the `?commonjs-proxy` flag ([#16238](https://github.com/tailwindlabs/tailwindcss/pull/16238))
1717
- Fix `order-first` and `order-last` for Firefox ([#16266](https://github.com/tailwindlabs/tailwindcss/pull/16266))
18+
- Ensure `NODE_PATH` is respected when resolving JavaScript and CSS files ([#16274](https://github.com/tailwindlabs/tailwindcss/pull/16274))
1819

1920
## [4.0.3] - 2025-02-01
2021

packages/@tailwindcss-node/src/compile.ts

+5
Original file line numberDiff line numberDiff line change
@@ -193,12 +193,15 @@ async function importModule(path: string): Promise<any> {
193193
}
194194
}
195195

196+
const modules = ['node_modules', ...(process.env.NODE_PATH ? [process.env.NODE_PATH] : [])]
197+
196198
const cssResolver = EnhancedResolve.ResolverFactory.createResolver({
197199
fileSystem: new EnhancedResolve.CachedInputFileSystem(fs, 4000),
198200
useSyncFileSystemCalls: true,
199201
extensions: ['.css'],
200202
mainFields: ['style'],
201203
conditionNames: ['style'],
204+
modules,
202205
})
203206
async function resolveCssId(
204207
id: string,
@@ -227,13 +230,15 @@ const esmResolver = EnhancedResolve.ResolverFactory.createResolver({
227230
useSyncFileSystemCalls: true,
228231
extensions: ['.js', '.json', '.node', '.ts'],
229232
conditionNames: ['node', 'import'],
233+
modules,
230234
})
231235

232236
const cjsResolver = EnhancedResolve.ResolverFactory.createResolver({
233237
fileSystem: new EnhancedResolve.CachedInputFileSystem(fs, 4000),
234238
useSyncFileSystemCalls: true,
235239
extensions: ['.js', '.json', '.node', '.ts'],
236240
conditionNames: ['node', 'require'],
241+
modules,
237242
})
238243

239244
async function resolveJsId(

0 commit comments

Comments
 (0)