我在import { browser } from "protractor";
中遇到错误并抛出***语法错误:无法在命令行中的模块***外部使用import语句。
我用 typescript ,摩卡咖啡和量角器。
下面是mochaOpts
:
mochaOpts: {
bail: false,
ui: 'bdd',
reporter: 'spec',
compiler: 'ts:ts-node/register'
},
下面是package.json中的依赖项:
"dependencies": {
"@babel/cli": "^7.7.4",
"@babel/preset-env": "^7.7.4",
"@babel/register": "^7.7.4",
"@types/mocha": "^7.0.1",
"@types/node": "^13.7.6",
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"graphviz": "0.0.9",
"lodash": "^4.17.15",
"minimist": "^1.2.0",
"mocha": "^6.2.2",
"npm-failsafe": "^0.4.1",
"protractor": "^5.4.2",
"rimraf": "^2.7.1",
"ts-node": "^8.5.4",
"tslint": "^5.20.1",
"typescript": "^3.8.2",
"typescript-logging": "^0.6.4",
"webdriver-manager": "^12.1.7",
"yargs": "^13.3.0"
}
下面是tsconfig.json:
{
"compileOnSave": true,
"compilerOptions": {
"baseUrl": ".",
"module": "commonjs",
"paths": { "*": ["types/*"] },
"outDir": "./dist/out-tsc",
"mapRoot": "./dist/out-tsc/",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"target": "es6",
"typeRoots": [
"node_modules/@types"
]
}
}
1条答案
按热度按时间pzfprimi1#
这对我很有效: