# Access package.json version from frontend

**URL:** <https://forums.bitovi.com/t/access-package-json-version-from-frontend/752>\
**Category:** StealJS\
**Created:** [November 13, 2017, 3:28pm UTC](https://forums.bitovi.com/t/access-package-json-version-from-frontend/752 "2017-11-13T15:28:03Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![robfoweraker](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/robfoweraker/32/284_2.png) [@robfoweraker](https://forums.bitovi.com/u/robfoweraker)\
**Post date:** [November 13, 2017, 3:28pm UTC](https://forums.bitovi.com/t/access-package-json-version-from-frontend/752/1 "2017-11-13T15:28:03Z")

</div>

Hi,

I’m just starting a new project where the application version has to be displayable in an about page on the frontend. I would like to get this from the package.json version. I am using stealjs with canjs (all latest available versions). I tried

```
import PackageJSON from '~/package.json';

```

This seems to work ok, but I get a warning from steal.

```
The module with address http://172.16.14.216:9001/package.json is being instantiated twice.
This happens when module identifiers normalize to different module names.

Modules:
    package.json!npm
projectname@1.0.0#package.json
    - http://172.16.14.216:9001/app/config.js

```

Or, maybe someone has a better idea on how to achieve what I am trying to achieve. I’m thinking that perhaps I do not have to explicitly import package.json (with a bit of luck).

Thanks in advance

Rob

---

<div class="post-metadata">

**Author:** ![matthewp](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/matthewp/32/77_2.png) [@matthewp](https://forums.bitovi.com/u/matthewp)\
**Post date:** [November 14, 2017, 12:14pm UTC](https://forums.bitovi.com/t/access-package-json-version-from-frontend/752/2 "2017-11-14T12:14:10Z")

</div>

Hi @robfoweraker, you’re doing everything right. That warning is a false positive. What version of steal are you on? it was fixed in 1.5.19. If you have 1.5.19 or 1.6.0 you should not see that any more. Let me know if you do.

---

<div class="post-metadata">

**Author:** ![robfoweraker](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/robfoweraker/32/284_2.png) [@robfoweraker](https://forums.bitovi.com/u/robfoweraker)\
**Post date:** [November 14, 2017, 5:12pm UTC](https://forums.bitovi.com/t/access-package-json-version-from-frontend/752/3 "2017-11-14T17:12:48Z")

</div>

Hi Matthew,

Thanks for the reply. I was using Steal 1.5.18. I will update and report back.

Rob

---

<div class="post-metadata">

**Author:** ![robfoweraker](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/robfoweraker/32/284_2.png) [@robfoweraker](https://forums.bitovi.com/u/robfoweraker)\
**Post date:** [November 15, 2017, 9:43am UTC](https://forums.bitovi.com/t/access-package-json-version-from-frontend/752/4 "2017-11-15T09:43:57Z")

</div>

HI Matthew,

I can confirm that I no longer see the warning in steal 1.6.0.

Thanks!

Rob

---

<div class="post-metadata">

**Author:** ![eben\_roux](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/eben_roux/32/380_2.png) [@eben\_roux](https://forums.bitovi.com/u/eben_roux)\
**Post date:** [November 15, 2017, 11:47am UTC](https://forums.bitovi.com/t/access-package-json-version-from-frontend/752/5 "2017-11-15T11:47:00Z")

</div>

Hi Rob,

What I have used previously is to add settings to the steal configuration in the `package.json` file:

```auto
  "steal": {
    "main": "main.js",
    "directories": {
      "lib": "src"
    },
    "npmAlgorithm": "flat",
    "plugins": [
      "steal-stache",
      "steal-css"
    ],
    "serviceBaseURL": "http://localhost:4040/api/", // <-- these 
    "debug": true, // <-- these 
    "localeVersion": "1" // <-- these 
  },

```

Then I use it like so where needed:

```auto
import loader from '@loader';

console.log(loader.debug);

```

Perhaps Matthew can provide some input as to the validity of this approach. I have also used a `configuration.js` file of sorts that just gets sucked in using a normal `<script>` tag and it contain some object that represents the required values:

```auto
mynamespace.configuration = {
  debug: false,
  someUrl: "http://myapi"
}

```

---

<div class="post-metadata">

**Author:** ![robfoweraker](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/robfoweraker/32/284_2.png) [@robfoweraker](https://forums.bitovi.com/u/robfoweraker)\
**Post date:** [November 15, 2017, 2:13pm UTC](https://forums.bitovi.com/t/access-package-json-version-from-frontend/752/6 "2017-11-15T14:13:34Z")

</div>

Hi Matthew,

I see the same problem in the production build using steal-tools@1.3.1. This problem was being hidden before as I was loading the bundle using the steal.production.js from the steal node\_modules, rather than dist/steal.production.js (I read the docs! things have changed a lot recently.)

@eben_roux : thanks - will think about it some more.

Rob

---

<div class="post-metadata">

**Author:** ![chasen](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/chasen/32/402_2.png) [@chasen](https://forums.bitovi.com/u/chasen)\
**Post date:** [November 15, 2017, 6:43pm UTC](https://forums.bitovi.com/t/access-package-json-version-from-frontend/752/7 "2017-11-15T18:43:46Z")

</div>

Hi @robfoweraker, do you get the same issue if you upgrade to the latest `steal-tools` (1.9.2 as of right now)?

---

<div class="post-metadata">

**Author:** ![robfoweraker](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/robfoweraker/32/284_2.png) [@robfoweraker](https://forums.bitovi.com/u/robfoweraker)\
**Post date:** [November 15, 2017, 8:12pm UTC](https://forums.bitovi.com/t/access-package-json-version-from-frontend/752/8 "2017-11-15T20:12:59Z")

</div>

Hi @chasen, In fact I was building with steal-tools 1.9.1 (confused it with steal-css 1.3.1). I upgraded to 1.9.2 and there is no longer a warning message.

Thanks!  
Rob
