【问题标题】:Webpack config not in strict mode, don't want to change the codeWebpack 配置不是严格模式,不想更改代码
【发布时间】:2018-06-22 20:37:53
【问题描述】:

我正在尝试构建 BitShares UI 的生产 webpack https://github.com/bitshares/bitshares-ui

问题是 webpack 没有在严格模式下运行 不过,我不想更改代码。有没有办法强制以严格模式解释 webpack 配置,以避免这个问题?

Step 13/19 : RUN npm run build
 ---> [Warning] Your kernel does not support swap limit capabilities or the cgroup is not mounted. Memory limited without swap.
 ---> Running in 7cfc6910af6a

 BitShares2-light@2.0.180108 build /build
 cross-env NODE_ENV=production webpack --env.prod

/build/webpack.config.js:70
        let outputDir = env.electron ? "electron" : env.hash ? `hash-history_${baseUrl.replace("/", "")}` : "dist";
        ^^^

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:374:25)
    at Object.Module._extensions..js (module.js:417:10)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)
    at Module.require (module.js:354:17)
    at require (internal/module.js:12:17)
    at requireConfig (/build/node_modules/webpack/bin/convert-argv.js:97:18)
    at /build/node_modules/webpack/bin/convert-argv.js:104:17
    at Array.forEach (native)

npm ERR! Linux 4.13.0-26-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "run" "build"
npm ERR! node v4.2.6
npm ERR! npm  v3.5.2
npm ERR! code ELIFECYCLE
npm ERR! BitShares2-light@2.0.180108 build: `cross-env NODE_ENV=production webpack --env.prod`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the BitShares2-light@2.0.180108 build script 'cross-env NODE_ENV=production webpack --env.prod'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the BitShares2-light package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     cross-env NODE_ENV=production webpack --env.prod
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs BitShares2-light
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls BitShares2-light
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /build/web/npm-debug.log
The command '/bin/sh -c npm run build' returned a non-zero code: 1
danielcastaneda@kwan-0080:~/WORK/BitPESO/bitshares-docker/build$ 

【问题讨论】:

  • 该错误与严格模式无关。您需要更高版本的 javascript 才能运行该代码。
  • 嗯...让我看看使用更新版本的节点是否可以解决它...谢谢
  • 什么 Docker 版本? Dockerfile 是什么?没有足够的信息让某人复制。
  • 谢谢大家。问题是我正在拉旧版本的节点。或者与此相关的东西。现在已经解决了这个问题。谢谢大卫:)

标签: javascript node.js docker webpack


【解决方案1】:

请检查您的 nodejs 版本。 BitShares-UI 依赖节点 Node.js,需要 8+ 版本。 在 Ubuntu 和 OSX 上,安装 Node 的最简单方法是使用 Node 版本管理器。 要为 Linux/OSX 安装 NVM,只需将以下内容复制粘贴到终端中:

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.30.2/install.sh | bash
nvm install v9
nvm use v9

运行后npm run build

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-12-10
    • 2020-11-07
    • 1970-01-01
    • 2019-07-08
    • 1970-01-01
    • 2015-05-06
    • 2011-03-09
    相关资源
    最近更新 更多