ReactJS部署应用报错Cannot copy to clipboard: Command failed: xsel --clipboard --input

新手上路,请多包涵

我正在尝试在我的 Ubuntu 16.04 服务器中部署 ReactJS 应用程序,但是当我执行命令时:

serve -s build

这是我的 package.json 文件:

 {
  "name": "client",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "bootstrap": "^4.3.1",
    "history": "^4.9.0",
    "jquery": "^3.4.0",
    "moment": "^2.24.0",
    "popper.js": "^1.15.0",
    "react": "^16.8.6",
    "react-dom": "^16.8.6",
    "react-router-dom": "^5.0.0",
    "react-scripts": "2.1.8"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": [
    ">0.2%",
    "not dead",
    "not ie <= 11",
    "not op_mini all"
  ]
}

我收到此错误:

 ERROR: Cannot copy to clipboard: Command failed: xsel --clipboard --input
xsel: Can't open display: (null)
: Inappropriate ioctl for device

   ┌──────────────────────────────────────────────────┐
   │                                                  │
   │   Serving!                                       │
   │                                                  │
   │   - Local:            http://localhost:5000      │
   │   - On Your Network:  http://server_IP:5000   │
   │                                                  │
   └──────────────────────────────────────────────────┘

但是该应用程序未加载并且无法在端口 5000 访问。

我怎么知道这个?

原文由 Dave 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 1.5k
2 个回答

我有同样的问题,我通过添加“-n”选项来解决它。

”-n, –no-clipboard 不要将本地地址复制到剪贴板”

原文由 Amber 发布,翻译遵循 CC BY-SA 4.0 许可协议

我通过将 nginx /build 我的 ReactJS 项目的文件夹,特别是 index.html 文件来避免这个问题

这样我就没有问题中描述的问题,因为我不再使用 serve -s build 命令执行服务。

原文由 Dave 发布,翻译遵循 CC BY-SA 4.0 许可协议

推荐问题