-1

I want to use NPM package in my index.js file without installing it with package manager, i don't have a HTML file, i only have index.js file which is executed with node index.js command when i have to use this file anywhere, so i can't use CDN. Is there any way i can use the package in my js file without installing it and without using CDN. Or is there any way we can require or import a package locally in js file.

Nasyx Nadeem
  • 241
  • 2
  • 12
  • [`crypto` is a node core module](https://nodejs.org/api/crypto.html). – CherryDT Oct 29 '22 at 16:48
  • Why are you not willing to use NPM? What objective are you trying to accomplish? The feels like an XY question that doesn't really explain the real objective/problem here. You can copy modules from NPM and just include them in your own source. Not sure why you'd do that since you orphan that code from future bug fixes and improvements, but you can. – jfriend00 Oct 29 '22 at 18:34

2 Answers2

1

You can use the built-in require function to import all node.js modules.

const crypto = require("node:crypto");
codingtuba
  • 366
  • 2
  • 13
1

This package crypto is no longer supported and has been deprecated. To avoid malicious use, npm is hanging on to the package name.

It's now a built-in Node module. If you've depended on crypto, you should switch to the one that's built-in.

you can use it by : const crypto = require("crypto");