我正在关注Angular Tour of Heroes tutorial。
我在加载应用程序localhost:3000时立即在Chrome浏览器(v47)中收到以下错误。相同的应用程序不会在Firefox(v45)中产生错误:
SyntaxError:块范围的声明(let,const,function,class) 尚未支持在eval(native)at的严格模式之外 SystemJSLoader .__ EXEC (http://localhost:3000/node_modules/systemjs/dist/system.src.js:1555:18) 在entry.execute (http://localhost:3000/node_modules/systemjs/dist/system.src.js:4035:18) 在linkDynamicModule (http://localhost:3000/node_modules/systemjs/dist/system.src.js:3300:32) 在链接 (http://localhost:3000/node_modules/systemjs/dist/system.src.js:3135:11) 在Object.execute (http://localhost:3000/node_modules/systemjs/dist/system.src.js:3510:13) 在doDynamicExecute (http://localhost:3000/node_modules/systemjs/dist/system.src.js:766:25) 在链接 (http://localhost:3000/node_modules/systemjs/dist/system.src.js:964:20) 在doLink (http://localhost:3000/node_modules/systemjs/dist/system.src.js:623:7) 在updateLinkSetOnLoad (http://localhost:3000/node_modules/systemjs/dist/system.src.js:669:18) 在 http://localhost:3000/node_modules/systemjs/dist/system.src.js:485:11 在ZoneDelegate.invoke (http://localhost:3000/node_modules/zone.js/dist/zone.js:334:26)at Zone.run (http://localhost:3000/node_modules/zone.js/dist/zone.js:126:43)at http://localhost:3000/node_modules/zone.js/dist/zone.js:713:57 at ZoneDelegate.invokeTask (http://localhost:3000/node_modules/zone.js/dist/zone.js:367:31)
这是正在使用的tsconfig.json文件(在教程中提供):
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": [ "es2015", "dom" ],
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true
}
}
答案 0 :(得分:0)
尝试将"alwaysStrict":true
添加到您的tsconfig中。正如它错误地说你需要使用严格模式,这个选项将为你做。
'use strict';