微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

配置 devcontainer 来运行电子应用程序?

如何解决配置 devcontainer 来运行电子应用程序?

问题

每次我在终端中使用命令 npm start 执行我的项目时,我都会收到以下错误消息:

>ProjectName@1.0.0 start /workspaces/ProjectName
>electron .

/workspaces/ProjectName/node_modules/electron/dist/electron: error while loading shared libraries: libxshfence.so.1: cannot open shared object file: No such file or directory
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ProjectName@1.0.0 start:`electron .`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the ProjectName@1.0.0 start script
npm ERR! This is probably not a problem with npm. There is likely additional logginh output above.

npm ERR! A complete log of this run can be found in:
npm ERR!   /home/node/.npm/_logs/2021-05-03T03_50_33_776Z-debug.log

访问 -> 2021-05-03T03_50_33_776Z-debug.log

我的 Dockerfile

ARG VARIANT="14-buster"
FROM mcr.microsoft.com/vscode/devcontainers/javascript-node:0-${VARIANT}

RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends xorg openBox libnss3 libasound2 libatk-adaptor libgtk-3-0

我的 devcontainer.json

{
"name": "Node.js","build": {
    "dockerfile": "Dockerfile","args": { "VARIANT": "14" }
},"settings": { 
    "terminal.integrated.shell.linux": "/bin/bash"
},"extensions": [
    "dbaeumer.vscode-eslint",],"remoteUser": "node"

}

注意:我已经尝试将 remoteUser 设为 root,但我不知道如何使用 devcontainer 将 chrome 置于 --no-sandBox 模式。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。