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: respect NODE_PATH env variable #4581

Merged
merged 2 commits into from Sep 27, 2022
Merged

fix: respect NODE_PATH env variable #4581

merged 2 commits into from Sep 27, 2022

Conversation

snitin315
Copy link
Member

@snitin315 snitin315 commented Sep 24, 2022

  • This is a bugfix
  • This is a feature
  • This is a code refactor
  • This is a test update
  • This is a docs update
  • This is a metadata update

For Bugs and Features; did you add new tests?

No.

Motivation / Use-Case

Porting changes from webpack/webpack-cli#3411

Reference webpack/webpack-cli#3355

Breaking Changes

No.

Additional Info

No.

@codecov
Copy link

codecov bot commented Sep 24, 2022

Codecov Report

Base: 92.06% // Head: 92.19% // Increases project coverage by +0.12% 🎉

Coverage data is based on head (27b6dcb) compared to base (e695c22).
Patch has no changes to coverable lines.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4581      +/-   ##
==========================================
+ Coverage   92.06%   92.19%   +0.12%     
==========================================
  Files          16       16              
  Lines        1639     1639              
  Branches      617      617              
==========================================
+ Hits         1509     1511       +2     
+ Misses        119      117       -2     
  Partials       11       11              
Impacted Files Coverage Δ
lib/servers/WebsocketServer.js 94.87% <0.00%> (+5.12%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Member

@alexander-akait alexander-akait left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Le't simprove this using:

if (typeof process.env.NODE_PATH !== undefined) {
 // Logic
}

I think we need the same change in webpack-cli and webpack itself, can you fix it? thank you

@alexander-akait
Copy link
Member

hm, from docs:

NODE_PATH is still supported, but is less necessary now that the Node.js ecosystem has settled on a convention for locating dependent modules. Sometimes deployments that rely on NODE_PATH show surprising behavior when people are unaware that NODE_PATH must be set. Sometimes a module's dependencies change, causing a different version (or even a different module) to be loaded as the NODE_PATH is searched.

And

Additionally, Node.js will search in the following list of GLOBAL_FOLDERS:

1: $HOME/.node_modules
2: $HOME/.node_libraries
3: $PREFIX/lib/node

Also paths on windows and linux are platform specific (and windows can has multiple paths separated by ;), so fix is not simple as I thought.

So I see two solutions here:

  1. Don't support it, but it can be paintful for some developers
  2. Fix our logic and handle all cases (not sure how we can handle $HOME and $PREFIX)

I am working on 2.

@alexander-akait
Copy link
Member

alexander-akait commented Sep 27, 2022

@snitin315 Found an easy solution, we should use it in webpack-cli/webpack

@alexander-akait
Copy link
Member

Also it should be after node_modules check

@snitin315
Copy link
Member Author

Nice solution, I'll update in webpack/webpack-cli 👍🏻

@alexander-akait alexander-akait merged commit b857e6f into master Sep 27, 2022
@alexander-akait alexander-akait deleted the fix-node-path branch September 27, 2022 01:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants