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
{{ message }}
Repository navigation
fail to resolve modules in node_modules if asbundle is install globally #23
If I install asbundle globally (at ~/.local/lib/node_modules/asbundle and ~/.local/bin/asbundle),
and try to execute it in another project ~/my-prj, the module in ~/my-prj/node_modules would fail to resolve.
I read the code and maybe follow patch can fix this issue:
diff --git a/index.js b/index.js
index ef383dc..5eba5b1 100644
--- a/index.js+++ b/index.js@@ -134,7 +134,7 @@ const parse = (options, base, file, cache, modules) => {
}
} else if (!/^[A-Z]/.test(module.value)) {
process.chdir(base);
- const name = require.resolve(module.value);+ const name = require.resolve(module.value, {paths: ['.']});
if (name !== module.value) addChunk(module, name);
else if (!CGJS) throw `unable to find "${name}" via file://${file}\n`;
}
asbundle change the dir, but the node.js resolve path relative to the original file path,
so we have to add the new path to the resolve option.
I am not sure this is correct or best practice; I have never deal with the require path resolution api before.
Activity
GHolk commentedon Aug 13, 2023
uhm..., I read the readme, and it states that global install should work, but it does not work.
maybe node.js change their api?