You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The tsconfig-paths package is resolving to a local JSON file rather than the expected JavaScript file from a node module binary. This behaviour is causing unexpected issues when attempting to resolve modules in a specific use case.
Navigate to the project directory and install dependencies: npm install
Run the main.js script: node main.js
The script is expected to resolve to a .js file within the node_modules/.bin directory. However, it incorrectly resolves to a local nx.json file instead.
Additionally we have a foo.json being resolved (To ensure that it was not the nx package which is causing the resolution issue)
Expected Behavior
The require.resolve function should resolve to the .js file specified in the node_modules/nx/bin/nx.js directory
Actual Behavior
The require.resolve function resolves to a local nx.json file.
Potential Cause and Solution
The issue seems to stem from the matchFromAbsolutePaths function in the tsconfig-paths package, specifically this block of code which uses require.extensions to include .json files in the resolution process.
Is there a way to exclude .json files from this resolution process, or to otherwise prioritize .js files from node_modules/{package}/bin/... over local .json files? This would ensure that the require.resolve function behaves as expected and resolves to the correct module.
The text was updated successfully, but these errors were encountered:
The
tsconfig-paths
package is resolving to a local JSON file rather than the expected JavaScript file from a node module binary. This behaviour is causing unexpected issues when attempting to resolve modules in a specific use case.Steps to Reproduce
Clone the repository: https://github.com/jaysoo/nx-tsconfig-path-issue
npm install
main.js
script:node main.js
The script is expected to resolve to a
.js
file within thenode_modules/.bin
directory. However, it incorrectly resolves to a localnx.json
file instead.Additionally we have a
foo.json
being resolved (To ensure that it was not the nx package which is causing the resolution issue)Expected Behavior
The
require.resolve
function should resolve to the.js
file specified in thenode_modules/nx/bin/nx.js
directoryActual Behavior
The
require.resolve
function resolves to a localnx.json
file.Potential Cause and Solution
The issue seems to stem from the
matchFromAbsolutePaths
function in thetsconfig-paths
package, specifically this block of code which usesrequire.extensions
to include.json
files in the resolution process.Is there a way to exclude
.json
files from this resolution process, or to otherwise prioritize.js
files fromnode_modules/{package}/bin/...
over local.json
files? This would ensure that therequire.resolve
function behaves as expected and resolves to the correct module.The text was updated successfully, but these errors were encountered: