Skip to content

Commit

Permalink
fix(node): npm modules are not resolved correctly (#9284)
Browse files Browse the repository at this point in the history
The current implementation of the node executor resolves all npm
modules that are referenced by the application from the root
node_modules folder. This behavior leads to runtime errors if any of
the project dependencies requires a different version of a package
than the project itself.

For example, if we have a project that depends on `express` in version
`4.17.3` (which on the other hand depends on `path-to-regexp` version
`0.1.7`) as well as on `path-to-regexp` in version `6.2.0`. In such
case `express` will throw a runtime error since it would load
`path-to-regexp` version `6.2.0` which is not API compatible.

For this reason, this commit changes the behavior of the node-executor
so that it completely ignores npm dependencies when calculating
resolve mappings.
  • Loading branch information
hellivan authored and FrozenPandaz committed Mar 21, 2022
1 parent 5a4b8e3 commit f24af57
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions packages/node/src/executors/node/node.impl.ts
Expand Up @@ -72,10 +72,9 @@ function calculateResolveMappings(
parsed.configuration
);
return dependencies.reduce((m, c) => {
if (!c.outputs[0] && c.node.type === 'npm') {
c.outputs[0] = `node_modules/${c.node.data.packageName}`;
if (c.node.type !== 'npm' && c.outputs[0] != null) {
m[c.name] = joinPathFragments(context.root, c.outputs[0]);
}
m[c.name] = joinPathFragments(context.root, c.outputs[0]);
return m;
}, {});
}
Expand Down

0 comments on commit f24af57

Please sign in to comment.