I'm currently migrating a monolith Angular app into an Angular NX monorepo. The footer component in the monolith accesses the 'version' in the package.json. In the monorepo, the footer component lives in a lib, but I have no idea how to access the package.json file. Can someone please tell me how
Asked
Active
Viewed 746 times
2
-
Any of these should work for you: https://stackoverflow.com/questions/9153571/is-there-a-way-to-get-version-from-package-json-in-nodejs-code – Joosep Parts Mar 23 '22 at 05:35
-
Unfortunately not. I can't access the files in the root folder of the monorepo from my lib – CaptainMorgan Mar 23 '22 at 22:12
1 Answers
0
I had the same issue. Package.json
can't be accessed from a lib project, although it can be accessed from an app project. Taking this into consideration, you can create an InjectionToken
which would hold the version.
Provide the token at the app level, and then inject it anywhere you need it.
It is generally a good practice to provide environment-related data at the app level.

Dominik Białecki
- 1
- 1