繁体   English   中英

在严格模式下使用const(角度2)

[英]Use of const in strict mode (Angular 2)

我的节点版本是v9.3.0,npm版本是5.5.1。 我正在尝试使用以下方法创建和运行示例项目:

ng new test;
ng serve -o;

angular cli可以成功编译程序,但是我的浏览器页面为空白,控制台日志显示为:

未捕获的SyntaxError:在严格模式下使用const。

首先,我该如何避免这个错误? 在这种情况下,如何启用严格模式?

编辑:

{
  "compileOnSave": false,
  "compilerOptions": {
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es5",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2017",
      "dom"
    ]
  }
}

类似的问题解决在下面讨论GitHub的链接

以下是问题的处理方式,尝试执行此操作可以帮助您解决问题。

如果您具有更新之前的可用版本,请转到该安装并使用:

npm shrinkwrap 
or npm shrinkwrap --dev

然后将创建一个新文件

npm-shrinkwrap.json

检查该文件,并确保已创建依赖项。 通常,此文件具有所有现有的依赖项。 将该文件放在运行npm install的文件夹中。 NPM将使用旧版本,并且应该可以运行。

或者,您可以删除所有不相关的依赖项,并仅保留具有请求依赖项的node-sass。

        "node-sass": {
        "version": "2.1.1",
        "from": "node-sass@>=2.0.1 <3.0.0",
        "resolved": "https://registry.npmjs.org/node-sass/-/node-sass-2.1.1.tgz",
        "dependencies": {
          "request": {
            "version": "2.79.0",
            "from": "request@>=2.53.0 <3.0.0",
            "resolved": "https://registry.npmjs.org/request/-/request-2.79.0.tgz",
          },
        }
      },

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM