我已经看到其他一些答案和GitHub问题来描述这一点,但是我无法找到解决方案。尝试开玩笑时,我感到恐惧SyntaxError: Unexpected token export
。
project/node_modules/@agm/core/index.js:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){export * from './directives';
运行这些测试的代码可以正常工作。错误似乎来自玩笑本身。 似乎就像玩笑一样正在转换文件,但我可能是错的。
我的笑话配置是
"jest": {
"preset": "jest-preset-angular",
"setupTestFrameworkScriptFile": "<rootDir>/setup-jest.ts",
"transformIgnorePatterns": [
"node_modules"
]
}
我尝试将transformIgnorePatterns
更新为"<rootDir>/node_modules/(?!@agm)"
和"node_modules/(?!@agm)"
,"node_modules/(?!@agm/core)"
,但似乎没有任何改变。
如何开玩笑以正确处理从@agm/core
导入的文件?
答案 0 :(得分:0)
要使其正常工作,我需要进行一些更改。这将解决在将@agm/core
用于Angular 6应用程序并与玩笑一起使用时解决此问题的问题。
yarn add --dev babel-preset-env
您应该已经拥有babel-jest
。
然后更新您的笑话配置:
"transform": {
"^.+\\.js": "<rootDir>/node_modules/babel-jest"
},
"transformIgnorePatterns": [
"<rootDir>/node_modules/(?!@agm)"
]
如果您没有.babelrc
,则还需要添加{
"presets": "babel-preset-env"
}
来使用:
#Requires -Modules @{ModuleName='AWSPowerShell.NetCore';ModuleVersion='3.3.335.0'}
$pw = convertto-securestring -AsPlainText -Force -String "Password"
$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist "UserID",$pw
$s = new-pssession -computername "AWSECS2DNS" -credential $cred
Invoke-Command -Session $s -ScriptBlock {Get-Service}
这可能适用于需要安装babel转换的其他库。
答案 1 :(得分:0)
我想为babel 7+添加它,而不是.babelrc,请使用 babel.config.js :
module.exports = {
presets: ['babel-preset-env'],
}