node.js - 在 docker 容器内的路径中找不到 Phantomjs
问题描述
我正在尝试在以 Node 8 作为基础映像的 docker 容器中安装一堆依赖项。docker 映像在 Ubuntu 上构建并运行良好,但是当我在 OS XI 上尝试时出现此错误:
Error making request.
Error: getaddrinfo EAI_AGAIN github.com:443
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:67:26)
Please report this full log at https://github.com/Medium/phantomjs
npm WARN backend@1.0.0 No repository field.
npm WARN backend@1.0.0 No license field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! phantomjs-prebuilt@2.1.16 install: `node install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the phantomjs-prebuilt@2.1.16 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Dockerfile:
FROM node:8-alpine
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm install
COPY . /app
# ADD MONGOURL ENV HERE
EXPOSE 5000
CMD ["npm", "start"]
这是我所有的依赖项:
"dependencies": {
"body-parser": "^1.18.3",
"compression": "^1.7.3",
"cors": "^2.8.4",
"express": "^4.16.4",
"html-parse-stringify": "^1.0.3",
"jsonwebtoken": "^8.3.0",
"lodash": "^4.17.11",
"mongoose": "^5.3.3",
"morgan": "^1.9.1",
"passport": "^0.4.0",
"passport-facebook": "^2.1.1",
"passport-google-oauth": "^1.0.0",
"query-string": "^6.2.0",
"request": "^2.88.0",
"signalr-client": "0.0.19", // 90% sure this is the one installs phantomjs
"socket.io": "^2.1.1",
"swagger-ui-express": "^4.0.1"
},
为什么会这样?我认为 docker 应该解决这样的问题。
解决方案
npm install phantomjs-prebuilt --phantomjs_cdnurl=http://cnpmjs.org/downloads
推荐阅读
- c++ - 堆栈变量超出范围时是否被释放?
- angular - 使用 Angular Universal 和 Webpack Server 时未定义 @ng-idle/core 文档
- sql - 如何使用gorm更新sql中的嵌套表?
- kubernetes - 如何在 Google Cloud Platform 上部署 GRPC 服务器和客户端?
- typo3 - 是否可以禁用 TYPO3 TCA 记录的翻译
- php - 如何禁用 symfony 表单中的必填字段?
- css - 如何正确生成 Sass 主题
- java - inputStream = new FileInputStream(path) 不工作
- mysql - 可以使用分析/窗口函数来查找以其他单词开头的单词子集吗?
- dart - Flutter - 基于第一个下拉列表中选择的选项的下拉选项