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;

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.