Javascript 在firebase云函数中使用导入

Javascript 在firebase云函数中使用导入,javascript,node.js,firebase,google-cloud-functions,Javascript,Node.js,Firebase,Google Cloud Functions,我正在尝试在节点版本为12的本地计算机上运行firebase云函数,其“服务”:“firebase模拟器:启动--仅函数”。 我无法使用.mjs扩展名,因为如果我使用.mjs firebase将无法识别该扩展名,并导致以下错误: require() of ES modules is not supported. require() of /home/rumesh/IdeaProjects/firebaseapp/functions/index.js from /usr/local/lib/nod

我正在尝试在节点版本为12的本地计算机上运行firebase云函数,其“服务”:“firebase模拟器:启动--仅函数”。
我无法使用
.mjs
扩展名,因为如果我使用.mjs firebase将无法识别该扩展名,并导致以下错误:

require() of ES modules is not supported.
require() of /home/rumesh/IdeaProjects/firebaseapp/functions/index.js from /usr/local/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /home/rumesh/IdeaProjects/firebaseapp/functions/package.json. 
错误:找不到模块“/home/rumesh/IdeaProjects/firebaseapp/functions”

无法在package.json中使用
“type”:module
,此错误为:

require() of ES modules is not supported.
require() of /home/rumesh/IdeaProjects/firebaseapp/functions/index.js from /usr/local/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /home/rumesh/IdeaProjects/firebaseapp/functions/package.json. 
在这种情况下,如何在不使用require语句的情况下使用import语句?

对此提出了一个问题,因为它是受支持的运行时的一部分