admin管理员组文章数量:1427755
I am trying to create a config file in js for all my keys. The problem is that i am not able to export and export the file. Here is the code and the error:
config.js:
export const mailchimpKey ='KEY'
app.js:
//jshint esversion: 6
const config = require('./config');
I have the folowing error when starting my node server:
C:\Code\boootstrap\boootstrap\src\newsletter\config.js:1
(function (exports, require, module, __filename, __dirname) { export const mailchimpKey ='KEY'
^^^^^^
SyntaxError: Unexpected token export
at new Script (vm.js:79:7)
at createScript (vm.js:251:10)
at Object.runInThisContext (vm.js:303:10)
at Module._pile (internal/modules/cjs/loader.js:657:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
[nodemon] app crashed - waiting for file changes before starting...
I read somewhere that I need babel set up to use import/export. Is that true? I tried installing this but not sure I set it up well
I am trying to create a config file in js for all my keys. The problem is that i am not able to export and export the file. Here is the code and the error:
config.js:
export const mailchimpKey ='KEY'
app.js:
//jshint esversion: 6
const config = require('./config');
I have the folowing error when starting my node server:
C:\Code\boootstrap\boootstrap\src\newsletter\config.js:1
(function (exports, require, module, __filename, __dirname) { export const mailchimpKey ='KEY'
^^^^^^
SyntaxError: Unexpected token export
at new Script (vm.js:79:7)
at createScript (vm.js:251:10)
at Object.runInThisContext (vm.js:303:10)
at Module._pile (internal/modules/cjs/loader.js:657:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
[nodemon] app crashed - waiting for file changes before starting...
I read somewhere that I need babel set up to use import/export. Is that true? I tried installing this but not sure I set it up well
Share Improve this question asked Jun 6, 2019 at 11:15 labellelabelle 4505 silver badges23 bronze badges1 Answer
Reset to default 4Can you try this:
module.exports={
mailchimpKey:'KEY'
}
Instead of your code in config.js
本文标签: javascriptImport configjs file in another fileStack Overflow
版权声明:本文标题:javascript - Import config.js file in another file - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745507578a2661316.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论