mac全局安装electron报错解决

mac 280

sudo npm install -g electron

出现如下报错信息,大概意思就是没有创建临时目录的权限

(node:6839) UnhandledPromiseRejectionWarning: Error: EACCES: permission denied, mkdtemp ‘/usr/local/lib/node_modules/electron/electron-download-hhDElT’
(node:6839) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `–unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)

解决方案:

sudo npm install -g electron –unsafe-perm=true –allow-root

喜欢 (0)