我正在使用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) 我想用selenium-webdriver登录facebook.com.
var webdriver = require('selenium-webdriver'),
By = require('selenium-webdriver').By,
until = require('selenium-webdriver').until;
var driver = new webdriver.Builder()
.forBrowser('firefox')
.build();
driver.get('https://www.facebook.com/login');
driver.findElement(By.id('email')).sendKeys('****');
driver.findElement(By.id('pass')).sendKeys('*****');
driver.findElement(By.id('loginbutton')).click();
driver.findElement(By.linkText('Settings')).then(function(element) {
console.log('Yes, found the element');
}, function(error) {
console.log('The element was not found, as expected');
});
driver.quit();
Run Code Online (Sandbox Code Playgroud)
这是错误的:
Run Code Online (Sandbox Code Playgroud)/home/shubham/node_modules/selenium-webdriver/index.js:25 const builder = require('./builder'); ^^^^^ SyntaxError: Use of const in strict mode. at Module._compile (module.js:439:25) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Module.require (module.js:364:17) at require (module.js:380:17) at Object.<anonymous> (/home/shubham/Music/amazon_login/test_22_4_16/sel_login.js:1:79) at Module._compile (module.js:456:26) at Object.Module._extensions..js …
我正在运行Visual Studio 2017并使用Task Runner来运行我的任务gulpfile.我最近更新了一个gulp任务到ES6,现在我收到此错误:
Failed to run "C:\Users\nz9rcn\Code\WebUI\Gulpfile.js"...
cmd.exe /c gulp --tasks-simple
C:\Users\nz9rcn\Code\WebUI\gulp-tasks\lesslint.js:5
let fail = false;
^^^
SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:373:25)
at Object.Module._extensions..js (module.js:404:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at task (C:\Users\nz9rcn\Code\WebUI\gulpfile.js:24:25)
at Object.<anonymous> (C:\Users\nz9rcn\Code\WebUI\gulpfile.js:37:23)
at Module._compile (module.js:397:26)
找不到调整导致此错误的设置的地方(严格模式).请帮忙.谢谢
我是Webpack,Visual Studio和Task Runner的新手,但这些是我被告知要在工作中安装/使用的,所以我正在努力弄清楚如何使它全部工作.我刚刚使用NPM全局安装webpack和webpack-cli的新副本.我将Task Runner插件安装到Visual Studio,并使用提供的Run> Development选项.神秘的是,我的唯一机器出现以下错误,没有人知道原因:
C:\Users\[me]\AppData\Roaming\npm\node_modules\webpack\bin\webpack.js:3
let webpackCliInstalled = false;
^^^
SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:373:25)
at Object.Module._extensions..js (module.js:404:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Function.Module.runMain (module.js:429:10)
at startup (node.js:139:18)
at node.js:999:3
Process terminated with code 1.
Run Code Online (Sandbox Code Playgroud)
我正在使用最新版本的NodeJS和NPM.任何想法为什么未经修改的webpack下载会抛出块范围错误?
编辑:
我看到这个问题引起了一些关注,所以我想我应该提一下问题已经解决了.不幸的是,解决方案是完全卸载webpack和webpack-cli并重新安装它们.然后就行了.为什么...?谁知道?我听说其他人也遇到过这个问题,虽然我从第一次开始就没有复制过.