-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Local node module (not npm registry) does not load with --node_modules-dir flag #18474
Comments
Ok, I had previously used into my
But now, when I simply use: this time, I get the following error:
|
One workaround could be to use the import map for loading a local node module without using That would be possible if deno could somehow deduce internally from the import map value that it has to deal with a node module:
|
Though it is confusing from a node.js perspective, this is a minor issue, so I close it. |
@abflow I didn't find anything indicating that this has been resolved, so I don't think it should be closed — AFAICT, Deno can't yet load Node modules from the local filesystem. Ref: https://deno.land/[email protected]/node/package_json Repro:Local Node module
{
"name": "local_tools",
"version": "0.1.0",
"type": "module",
"main": "index.mjs"
}
export { default as shout } from "./shout.mjs";
/** @param {string} text */
function shout(text) {
console.log(text.toUpperCase());
}
export default shout; Deno app
{
"name": "deno_app",
"version": "0.1.0",
"dependencies": {
"local_tools": "file:../local_tools"
}
}
import { shout } from "local_tools";
shout("hello world"); In the terminal
|
@jsejcksn @denizdogan You're right... sorry about that. I reopen the issue. |
Hello, is there any update on this issue. Thank you |
No, there was a bit of work done on the patch feature for JSR (#25068), but not for npm yet (I tried, but cut it out of the scope of the initial implementation). |
Are there any work-arounds? - this would be helpful for testing/debugging an NPM library with a deno project locally. |
I found a hacky workaround for this
Here is an example of a deno task you can run to create the symlink assuming you placed the local dependency at the root of your deno project
WARNING: this may not always work. Notably, it has two downsides:
|
Trying to use Deno in Nx, total nightmare, thought this may help. |
I have a node module
test_node
which is locally installed within the deno project into anode_modules
folder via:npm install --save ../test_node
package.json:
When I run with the node-modules-dir flag:
deno run -A --node-modules-dir index.js
I get the following error:
error: npm package 'test_node' does not exist
The text was updated successfully, but these errors were encountered: