Ian Triggs
Ian Triggs

Reputation: 11

Tutorial "GOOGLE_MAPS_API_KEY=<your key here> ember s" not working

In the ember.js tutorial section "Services and Utilities" at the part where you need to add

GOOGLE_MAPS_API_KEY=<your key here> ember s

I get the error

'GOOGLE_MAPS_API_KEY' is not recognized as an internal or external command,
operable program or batch file.

I know I have followed everything before correctly. And yes i did replace with a valid google maps api key.

Thanks for your help!

Upvotes: 1

Views: 1261

Answers (4)

Lekens
Lekens

Reputation: 1967

Yes this will not work on the window terminal because those variables(GOOGLE_MAPS_API_KEY, LEAFLET_MAPS_API_KEY) are not set in the environment.

However you need to set it first before.

On the terminal do:

set VARIABLE_NAME=value

e.g:

set LEAFLET_MAPS_API_KEY=56789ug67890-

Then you can continue to run ember serve

Upvotes: 0

NamotoD
NamotoD

Reputation: 49

  1. Set your Environment Variable: i.e in Windows 10 Powershell do: $env:YOUR_VARIABLE = 'some_value'
  2. Just do: ember s $env:YOUR_VARIABLE

Upvotes: 0

rcatwr
rcatwr

Reputation: 41

I encountered the the same issue using the ember CLI in Windows and just ended up editing the environment.js file in the ember-simple-google-maps directory by pasting in an API key.

specifically, on line 9:

apiKey: process.env.GOOGLE_MAPS_API_KEY || '<your api key here>'

Upvotes: 0

Etherman
Etherman

Reputation: 1867

There is a bit of a discussion about this here: https://github.com/emberjs/guides/issues/1554

The tutorial omits the SET command from before the key name.

On Windows you may use the following before launching with "ember s"

C:\...> set GOOGLE_MAPS_API_KEY=<your key>
C:\...> ember s

However, it still seems to work with a blank/unset API key (but windows powershell makes it very hard to tell if environment variables set or removed are really there or are gone or still have old values, but that's another story). If I set it to a bogus key then it fails.

The tutorial certainly does not explain how an environment variable on a local dev machine fits in with a deployed application. Presumably you need to set the env var before building the app for deployment (you will need a key on a live project, and may want different keys on different projects) (usage is presumably throttled without a valid API key).

Upvotes: 2

Related Questions