3

I want to import config.js which includes project's API keys. But It returns undefined.

//config.js
var config = {
   fbAPI: "key"
}

-

//nuxt.config.js

const cfg = require('./config')
env: {
   fbAPI: cfg.apiKey
}

Is this problem about run-time or am I missing something?

1 Answer 1

4

You missed modules.export at the end of config.js. The file should look following:

var config = {
   fbAPI: "key"
}

module.exports = config;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.