当前位置: 首页 > 面试题库 >

严格模式外尚不支持块范围的声明

韩智敏
2023-03-14
问题内容

我在Homestead流浪者盒子上运行 Laravel 5.4 。我已经使用npm install命令安装了所有npm依赖项。那没有产生任何错误。

在我的 webpack.min.js 文件中,我有:

const { mix } = require('laravel-mix');

/*
 |--------------------------------------------------------------------------
 | Mix Asset Management
 |--------------------------------------------------------------------------
 |
 | Mix provides a clean, fluent API for defining some Webpack build steps
 | for your Laravel application. By default, we are compiling the Sass
 | file for the application as well as bundling up all the JS files.
 |
 */

mix.js([
        'resources/assets/plugins/jquery-1.11.3.min.js',
        'resources/assets/plugins/bootstrap/js/bootstrap.min.js',
        'resources/assets/js/main.js'
    ], 'public/js'
);

mix.combine([
       'resources/assets/plugins/bootstrap/css/bootstrap.min.css',
       'resources/assets/plugins/font-awesome/css/font-awesome.css',
       'resources/assets/css/styles.css'
   ], 'public/css/all.css');

当我要运行时npm run production,出现以下错误:

> @ production /home/vagrant/projects/nielsvroman
> node node_modules/cross-env/bin/cross-env.js NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

/home/vagrant/projects/nielsvroman/node_modules/laravel-mix/setup/webpack.config.js:120
        let extractPlugin = new plugins.ExtractTextPlugin(
        ^^^

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:404:25)
    at Object.Module._extensions..js (module.js:432:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:311:12)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at requireConfig (/home/vagrant/projects/nielsvroman/node_modules/webpack/bin/convert-argv.js:96:18)
    at /home/vagrant/projects/nielsvroman/node_modules/webpack/bin/convert-argv.js:109:17
    at Array.forEach (native)

npm ERR! Linux 3.19.0-25-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "run" "production"
npm ERR! node v5.0.0
npm ERR! npm  v3.3.6
npm ERR! code ELIFECYCLE
npm ERR! @ production: `node node_modules/cross-env/bin/cross-env.js NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ production script 'node node_modules/cross-env/bin/cross-env.js NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js'.
npm ERR! This is most likely a problem with the  package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node node_modules/cross-env/bin/cross-env.js NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js
npm ERR! You can get their info via:
npm ERR!     npm owner ls
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/vagrant/projects/nielsvroman/npm-debug.log

这可能是什么问题?


问题答案:

我在Ubuntu上的旧版本的nodejs包也遇到了同样的问题。我刚刚更新到7.5,并且可以正常工作。

curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
sudo apt-get install -y nodejs


 类似资料:
  • 我遵循的角度英雄之旅教程。 加载应用程序localhost时,我立即在Chrome浏览器(v47)中收到以下错误:3000。同一应用程序在Firefox(v45)中不会产生错误: SyntaxError:SystemJSLoader的eval(本机)上的严格模式外尚不支持块作用域声明(let、const、函数、类)__执行官(http://localhost:3000/node_modules/s

  • 在本页和p5的文档中。Perlin noise的输出范围被描述为[0,1],但我发现的所有其他实现都有一个关于0的小范围对称,这似乎也是理论上应该保持的。Processing对柏林噪声的实施情况如何?他们有什么不同之处?比如说,我如何在python中复制这一点?

  • 问题内容: 我正在尝试做的是: 我正在尝试使用Java连接到[使用https]的Web Portal。我已经编写了使用Authenticator类提供用户凭据的代码。运行程序时出现异常: “ java.lang.UnsupportedOperationException:尚不支持” 我有张贴的代码: 第二次Try中引发了异常“ java.lang.UnsupportedOperationExcep

  • 除了正常的运行模式,JavaScript 还有第二种运行模式:严格模式(strict mode)。顾名思义,这种模式采用更加严格的 JavaScript 语法。 同样的代码,在正常模式和严格模式中,可能会有不一样的运行结果。一些在正常模式下可以运行的语句,在严格模式下将不能运行。 设计目的 早期的 JavaScript 语言有很多设计不合理的地方,但是为了兼容以前的代码,又不能改变老的语法,只能不

  • 概述 进入标志 如何调用 语法和行为改变 全局变量显式声明 静态绑定 增强的安全措施 禁止删除变量 显式报错 重名错误 禁止八进制表示法 arguments对象的限制 函数必须声明在顶层 保留字 参考链接 概述 除了正常运行模式,ECMAscript 5添加了第二种运行模式:“严格模式”(strict mode)。顾名思义,这种模式使得Javascript在更严格的条件下运行。 设立”严格模式“的

  • ECMAScript 5 最早引入了“严格模式”(strict mode)的概念。通过严格模式,可以在函数内部选择进行较为严格的全局或局部的错误条件检测。使用严格模式的好处是可以提早知道代码中存在的错误,及时捕获一些可能导致编程错误的ECMAScript 行为。 理解严格模式的规则非常重要,ECMAScript 的下一个版本将以严格模式为基础制定。支持严格模式的浏览器包括IE10+、Firefox