-1

I have a task of adding a version number to the UI in a react web app. Since my package.json file does contain a version number is it possible to use that value as a variable in my app? Ive tried importing the package.json but this does not work. Im not sure how I should approach this in a web app any advice would be helpful. This is the beginning of my package.json where the version number lives:

{
  "name": "emr",
  "version": "1.0.0",
  "description": "Reliant EMR",
  "main": "index.js",
...

Ive tried importing the package.json like this:

import React, { Component } from "react";
import { connect } from "react-redux";
import { Version } from "../../../package.json"

I've started this by only trying to get the value out of the Version

console.log(Version.version)
CourtneyJ
  • 142
  • 1
  • 13

1 Answers1

1

You don't need the {} in this case. Version is not exported. Just remove the brackets and use

import Version from "../../../package.json";
new QOpenGLWidget
  • 1,744
  • 2
  • 15
  • 28