Netlify throwing error when import/export modules, why?

659 Views Asked by At

I have an API key hidden in a file, I'm not using dotenv to do this, and I'm importing them into my javascript file via ES6 modules. Netlify allows build commands to build this when the app is deployed.

cd scripts && echo -e "const API_KEY = 'blahblahblah'; const HASH_KEY = 'blahblahblah'; const TIME_STAMP = 'ts=1'; const URL_ENDPOINT='blahblahblah';\n\nexport API_KEY, HASH_KEY, TIME_STAMP, URL_ENDPOINT;" > apikey.js

That is what I put into Netlify's deploy settings.

When I go to the deployed site, I get "Uncaught syntax error: unexpected token export".

The file is made correctly in the sources tab of the console. I'm at a loss for what I've done incorrectly, or what Netlify isn't interpreting correctly.

1

There are 1 best solutions below

0
On

I found the solution:

I was missing brackets in the build command, and after that I had to update some links from HTTP: to HTTPS:.

Thanks for trying to help out.