satanworker
satanworker12mo ago

How to link local NPM package with Deno

I have a package which has a couple of peer dependencies, which I want to link locally and patch. What is the way to do it? The structure of dist folder is .d.ts + .js files, which looks pretty normal to me, thank you in advance 🙇‍♂️
No description
1 Reply
Deno AI Helper
Deno AI Helper12mo ago
I wasn't able to find the answer to your question in the official Deno documentation. However, based on your message, it seems like you're trying to use an NPM package with Deno. Deno does not natively support NPM packages as it uses a different module system that is based on URLs and does not use the node_modules directory or package.json files. If you want to use code from an NPM package in Deno, you would typically need to find a Deno-compatible version of the package or convert the package to be Deno-compatible. This might involve ensuring that the package does not use Node.js-specific APIs without equivalent Deno APIs, and it may require you to import dependencies via URLs. For local development, you can import local files directly using file URLs in your Deno scripts. For example:
import { myFunction } from 'file:///absolute/path/to/your/module.js';
import { myFunction } from 'file:///absolute/path/to/your/module.js';
Remember that the advice provided here is not based on the Deno documentation, and you should double-check the accuracy of this advice. If you need to patch or modify the package, you would do so locally and then import it as shown above, ensuring that any dependencies are also accessible to Deno. If the package relies on Node.js-specific features, you may need to find or create Deno-specific alternatives.