stephan.peters
stephan.peters

Reputation: 1107

Get Npm dependency in node javascript file

I have a package.json file with certain dependencies. One of the dependencies is jquery. The system then downloads the files into the node_modules folder.

How can I get the version of a downloaded dependency from a Javascript file invoked by the node command?

I need to read the equivalent of npm view jquery version in a node JS file?

Upvotes: 0

Views: 420

Answers (2)

Milan Velebit
Milan Velebit

Reputation: 2017

Try using pkginfo, it should satisfy.

Upvotes: 0

Francois
Francois

Reputation: 3080

You can do

console.log(require('jquery/package.json').version);

It will give you the version of the package in your local node_modules.

Upvotes: 3

Related Questions