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

我想使用节点本机支持导入/导出与NPM包。 开始我运行cuccumberjs版本3.1.0。 但是,当我运行这个命令:

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

我收到一个错误:

 (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"; ^^^^^^ 

我所有的自动化testing都运行良好,直到我尝试将其中一个脚本转换为ES模块并导入它。 以下是该文件的一个片段:

runJsInBrowsers.mjs

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

package.json

 { "name": "tests", "version": "0.0.1", "description": "Test for testing.", "main": "index.js", "license": "UNLICENSED", "dependencies": { "chromedriver": "^2.0", "cucumber": "^3.1", "selenium-webdriver": "^3.0" }, "devDependencies": { } }