【问题标题】:Firebase init throwing "Use of const in strict mode" errorFirebase init 抛出“在严格模式下使用 const”错误
【发布时间】:2018-10-10 03:21:21
【问题描述】:

我使用

安装了 firebase 工具
sudo npm install -g firebase-tools

一切似乎都安装得很好。我已经安装了 npm 和 node.js,这些是版本: npm:2.11.3 节点:v0.12.7

但是当我尝试运行时

firebase init

从我的项目文件中,我得到了这个错误

    /usr/local/lib/node_modules/firebase-tools/node_modules/request/node_modules/hawk/node_modules/boom/lib/index.js:5
const Hoek = require('hoek');
^^^^^
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> (/usr/local/lib/node_modules/firebase-tools/node_modules/request/node_modules/hawk/lib/index.js:5:33)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)

我该如何解决这个错误?

【问题讨论】:

    标签: node.js firebase


    【解决方案1】:

    此错误是由于Node.js版本,您需要更新到8或更高版本。

    【讨论】:

    • 我运行了 brew upgrade node 并得到错误:节点 10.0.0 已经安装,但是当我运行 node -v 时它显示 v0.12.7。这是为什么呢?
    • 我对 MacOSX 不是特别精通。在 Ubuntu 中,我使用 NVM 而不是在 apt-get 中安装 Node.JS:github.com/creationix/nvm
    • 或许这会有所帮助:stackoverflow.com/questions/5056115/…
    猜你喜欢
    • 2017-10-11
    • 2019-07-15
    • 2016-08-15
    • 2014-05-01
    • 1970-01-01
    • 2019-01-31
    • 1970-01-01
    • 2016-07-14
    相关资源
    最近更新 更多