using npm packages in deno

Since deno 1.28, we can use npm packages.

So, can I do :

import package from "npm:@project/package@2.2.0";

in deno ?

Where will the temp npm modules get loaded to ?

The post you linked to describes a global cache path. It doesn’t say where this is, though.

If you wanted to have more control over your npm package directory, you could use the --node-modules-dir flag when you run your application, which creates a node_modules directory in the root of your app (similar to how npm works).

If you’re deploying your app from a Dockerfile, you could probably even put

RUN cd /path/to/your/app && deno cache --node-modules-dir your-apps-entry-point.ts

in the dockerfile to cache your modules before starting the app, if you wanted to optimize your app’s startup speed :slight_smile:

Ok - so I don’t want to know where the node_modules get loaded to - I was just wondering if the deno version at fly allows importing from npm or not and will it count towards our storage ? Are there any restrictions ?

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.