相关疑难解决方法(0)

SyntaxError:在严格模式下使用const

我正在使用node.js,并在我正在使用的一个js文件const"strict mode".当试图运行它时,我收到一个错误:

SyntaxError: Use of const in strict mode.
Run Code Online (Sandbox Code Playgroud)

这样做的最佳做法是什么?

编辑:

'use strict'
const MAX_IMAGE_SIZE = 1024*1024; // 1 MB
Run Code Online (Sandbox Code Playgroud)

javascript node.js

238
推荐指数
7
解决办法
24万
查看次数

Visual Studio Task Runner"SyntaxError:在严格模式下使用const."

使用Win10 Pro/VS2015和'网站'项目(不是asp.net,基本网站)

当尝试保存/重新加载gulpfile.js时,我收到错误消息(来自Task Runner Explorer /输出)

SyntaxError:在严格模式下使用const.

在目前的情况下,它正在窒息'gulp-changed'

我查看了可用的答案和评论:


在我的情况下,环境路径,$(PATH)已经包含节点的全局安装,但我需要将它移到$(DevEnvDir)路径之前,以便它将获得优先级. 在我的情况下,环境路径,$(PATH)已经包含节点的全局安装,但我需要将它移到$(DevEnvDir)路径之前,以便它将获得优先级.

(在提供正确答案后添加,谢谢@baao)

javascript node.js gulp

7
推荐指数
1
解决办法
2560
查看次数

如何列出 npm 中当前使用的 Node.js 版本和路径?

我目前遇到了与 Stackoverflow 问题相同的错误:SyntaxError: Use of const in strict mode? ,尽管我在尝试安装 Flux时得到了它。

我已经使用链接的 Stackoverflow 问题中显示的命令更新了系统的 Node.js 版本。

npm cache clean -f
sudo npm install -g n
sudo n stable
Run Code Online (Sandbox Code Playgroud)

当我运行时,node --version我得到了正确的版本,v8.2.1. 但是,当我通过 npm 安装模块时,我仍然收到警告,例如

npm WARN engine har-schema@1.0.5: wanted: {"node":">=4"} (current: {"node":"v0.10.25","npm":"1.3.10"})
Run Code Online (Sandbox Code Playgroud)

...这表明 npm 仍在使用旧版本的 Node。

有没有办法可以找到 npm 看到的 Node 版本,并且可以确定它的安装目录?

javascript bash ubuntu node.js

4
推荐指数
1
解决办法
2万
查看次数

赫斯基给出错误SyntaxError:在严格模式下使用const

我正在使用赫斯基Lint-stagedStylelint

  "scripts": {
    "precommit": "lint-staged",

  },
  "lint-staged": {
    "*.scss": ["stylelint --syntax scss"
    ]
  },
Run Code Online (Sandbox Code Playgroud)

OS - 最新的OSX

节点 - 6.10.0

NPM - 3.10.00

我收到了这个错误 git commit

> husky - npm run -s precommit

/Users/jitendravyas/app/node_modules/lint-staged/src/index.js:6
const path = require('path')
^^^^^
SyntaxError: Use of const in strict mode.
    at exports.runInThisContext (vm.js:73:16)
    at Module._compile (module.js:443:25)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (/Users/jitendravyas/app/node_modules/lint-staged/index.js:2:1)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js …
Run Code Online (Sandbox Code Playgroud)

git node.js stylelint husky lint-staged

3
推荐指数
1
解决办法
2163
查看次数

标签 统计

node.js ×4

javascript ×3

bash ×1

git ×1

gulp ×1

husky ×1

lint-staged ×1

stylelint ×1

ubuntu ×1