【问题标题】:How can I fix this error after installing Electron on Mac with command 'sudo npm install electron -g'在 Mac 上使用命令“sudo npm install electron -g”安装 Electron 后如何修复此错误
【发布时间】:2020-06-05 23:46:19
【问题描述】:

我在命令前加上了sudo,因为我在第一次尝试时遇到了'Permission Denied' 错误。建议以管理员身份运行该命令,或者最好还是删除/usr/local/lib/node_modules 处的整个电子文件夹并重新安装。我这样做并第二次安装它,但我仍然收到以下错误:

(node:85821) UnhandledPromiseRejectionWarning: Error: EACCES: permission denied, mkdtemp '/usr/local/lib/node_modules/electron/electron-download-KXtUtz'
(node:85821) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:85821) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

+ electron@8.0.1

added 85 packages from 93 contributors in 8.968s
➜  / electron -v

/usr/local/lib/node_modules/electron/index.js:14
    throw new Error(**'Electron failed to install correctly, please delete node_modules/electron and try installing again'**)

【问题讨论】:

    标签: javascript node.js macos npm electron


    【解决方案1】:

    这终于对我有用了:

    sudo npm install electron -g --unsafe-perm=true

    从此链接https://www.electronjs.org/docs/tutorial/installation

    【讨论】:

      【解决方案2】:

      这就是我使用全局标志安装 Electron 版本 8.2.2 的方式:

      npm install -g --unsafe-perm=true electron
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-06-07
        • 2021-01-04
        • 2021-12-16
        • 2014-07-06
        • 1970-01-01
        • 2014-07-04
        • 2017-07-13
        • 2017-10-20
        相关资源
        最近更新 更多