在严格模式下使用'const' [英] Use of 'const' in strict mode

查看:145
本文介绍了在严格模式下使用'const'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的节点版本是v9.3.0,npm版本是5.6.0,angular-cli版本是1.6.1。



每当我运行一个项目,我收到以下错误:



未捕获的语法错误:在严格模式下使用'const'。 





为什么会抛出此错误?我应该如何减轻它?



我尝试过:



我试着重新安装Node.js的和角CLI但不成功。

解决方案
下面是一个问题是如何在Git中进行处理,试图这可能会帮助您解决问题。



如果您在更新之前有工作版本,请转到该安装并使用:



'pre> NPM拆封
或NPM拆封--dev



然后一个新的文件将被创建

< br $>
npm-shrinkwrap.json



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



作为替代方案,您可以删除所有不相关的依赖项,并且只保留具有请求依赖性的node-sass。

node-sass:{
version:2.1.1,
from:node-sass @> = 2.0.1< ; 3.0.0,
已解决:https://registry.npmjs.org/node-sass/-/node-sass-2.1.1.tgz,
依赖项: {
request:{
version:2.79.0,
from:request @> = 2.53.0< 3.0.0,
的解决: https://registry.npmjs.org/request/-/request-2.79.0.tgz,
},
}
},


My node version is v9.3.0 and npm version is 5.6.0, and the angular-cli version being 1.6.1.

Whenever I run a project, I receive the following error :

Uncaught syntaxerror: use of 'const' in strict mode. 



Why is this error thrown ? How should I mitigate it ?

What I have tried:

I tried re-installing the node.js and angular-cli but in vain.

解决方案

Below is how the issue was handled in Git, trying this may help you resolve the issue.

If you have a working version prior to update go to that installation and use:

npm shrinkwrap 
or npm shrinkwrap --dev


then a new file will be created

npm-shrinkwrap.json

Check that file and make sure dependencies are created. Normally this file has all the existing dependencies. Put that file in the folder which you run npm install inside. NPM will use the old versions and should work.

As an alternative you can remove all unrelated dependencies and keep only node-sass with request dependency.

"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",
          },
        }
      },


这篇关于在严格模式下使用'const'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆