@@ -329,11 +329,38 @@ Limitations:
329
329
330
330
### Overriding NPM packages
331
331
332
- We plan to support NPM packages with the patch functionality described above,
333
- but until then if you have a ` node_modules ` directory, ` npm link ` can be used
334
- without change to accheive the same effect. This is typically done with
335
- ` { "nodeModulesDir": "manual" } ` set in the ` deno.json ` file. See also the
336
- documentation on [ ` node_modules ` ] ( /runtime/fundamentals/node/#node_modules )
332
+ Deno supports patching npm packages with local versions, similar to how JSR
333
+ packages can be patched. This allows you to use a local copy of an npm package
334
+ during development without publishing it.
335
+
336
+ To use a local npm package, configure the ` patch ` field in your ` deno.json ` :
337
+
338
+ ``` json
339
+ {
340
+ "patch" : [
341
+ " ../path/to/local_npm_package"
342
+ ],
343
+ "unstable" : [" npm-patch" ]
344
+ }
345
+ ```
346
+
347
+ This feature requires a ` node_modules ` directory and has different behaviors
348
+ depending on your ` nodeModulesDir ` setting:
349
+
350
+ - With ` "nodeModulesDir": "auto" ` : The directory is recreated on each run, which
351
+ slightly increases startup time but ensures the latest version is always used.
352
+ - With ` "nodeModulesDir": "manual" ` (default when using package.json): You must
353
+ run ` deno install ` after updating the package to get the changes into the
354
+ workspace's ` node_modules ` directory.
355
+
356
+ Limitations:
357
+
358
+ - Specifying a local copy of an npm package or changing its dependencies will
359
+ purge npm packages from the lockfile, which may cause npm resolution to work
360
+ differently.
361
+ - The npm package name must exist in the registry, even if you're using a local
362
+ copy.
363
+ - This feature is currently behind the ` unstable ` flag.
337
364
338
365
### Overriding HTTPS imports
339
366
0 commit comments