如何在版本9中使用Node.js本机导入/导出

时间:2017-11-07 17:17:02

标签: node.js es6-modules

我想使用Node本机支持导入/导出NPM包。首先,我正在运行cuccumberjs 3.1.0版。但是,当我运行此命令时:

audio {
  width:20px;
  height:30px;
  display: block
}

我收到错误:

/usr/local/bin/node --experimental-modules ./node_modules/.bin/cucumber-js

我的所有自动化测试运行正常,直到我尝试将我的一个脚本转换为ES模块并导入它。以下是该文件的摘录:

(node:42011) ExperimentalWarning: The ESM module loader is experimental. SyntaxError: Unexpected token import /full/path/to/test/directory/features/support/getWindowLocation.js:2 import {runJsInBrowser} from "./runJsInBrowser.mjs"; ^^^^^^

runJsInBrowsers.mjs

-

export default async function runJsInBrowser( browserDriver, windowFunc, waitForReturn = true, timeOut = 10000 ) { ... };

package.json

0 个答案:

没有答案