【发布时间】:2020-04-02 11:44:11
【问题描述】:
如果我导入这样的 js 文件:
const importedFile = require( './file1');
我可以看到 file1 的所有函数和控制台日志正在运行,但我无法运行或使用特定变量
如果我 console.log( importedFile ) 我得到这个:{} 空对象!
如何从 file1.js 中获取所有变量?
【问题讨论】:
-
你不能改变 const 值
-
没有人试图改变。只是为了阅读..
-
@DarrenSweeney — 这是 ES6 导入,而不是 Node 模块系统。
-
从那个链接我试过这个: import * as importedFile from './file1.js';给我这个:SyntaxError: Unexpected token *
标签: javascript node.js variables scope