Categories
JavaScript Answers

How to get version from package.json in Node.js code?

Spread the love

Sometimes, we want to get version from package.json in Node.js code.

In this article, we’ll look at how to get version from package.json in Node.js code.

How to get version from package.json in Node.js code?

To get version from package.json in Node.js code, we can import the content of package.json.

For instance, we write

import {
  version
} from './package.json';

to import the version property from package.json as a string.

Conclusion

To get version from package.json in Node.js code, we can import the content of package.json.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *