OP EDIT: if anyone else comes across this: the application was created using create-react-app , which restricts imports inside the src folder. However, if you upgrade reactive scripts to version 1.0.11 , this will allow you to access package.json.
I am trying to get the version number from package.json in my application.
I already tried these suggestions , but none of them worked, because I cannot access package.json because of the src folder (maybe because of the React, I'm new to this). Moving package.json to src then means that I cannot run npm install, npm version minorand npm run buildfrom my root folder. I tried using process.env.npm_package_version, but this leads to undefined.
I use Jenkins and I haven't configured it yet to push commits, but the only idea I have is to get the version from tags in GitLab, but I have no idea how to do this, and this will add an unnecessary repo dependency, therefore, I would really like to find an alternative.
EDIT: My file structure is similar:
|
|
|
|
|
|
|
|
, package.json Root.js, import packageJson from './../../package.json', :
./src/components/Root.js
: . /../../package.json, src/ . src/ . src/, node_modules/.