我正在使用docker-compose开发一个多模块docker nodejs应用程序。模块所需的natural节点包存在问题。它似乎无法执行它。我尝试使用RUN命令在运行中重建它,但没有任何改变。 这是尝试运行docker-compose up时的日志:
web_1 | /app/web-server/node_modules/natural/lib/natural/classifiers/classifier.js:32
web_1 | if (e.code !== 'MODULE_NOT_FOUND') throw e;
web_1 | ^
web_1 |
web_1 | Error: Error loading shared library /app/web-server/node_modules/webworker-threads/build/Release/WebWorkerThreads.node: Exec format error
web_1 | at Error (native)
web_1 | at Object.Module._extensions..node (module.js:597:18)
web_1 | at Module.load (module.js:487:32)
web_1 | at tryModuleLoad (module.js:446:12)
web_1 | at Function.Module._load (module.js:438:3)
web_1 | at Module.require (module.js:497:17)
web_1 | at require (internal/module.js:20:19)
web_1 | at bindings (/app/web-server/node_modules/bindings/bindings.js:81:44)
web_1 | at Object.<anonymous> (/app/web-server/node_modules/webworker-threads/index.js:1:105)
web_1 | at Module._compile (module.js:570:32)
web_1 | at Object.Module._extensions..js (module.js:579:10)
web_1 | at Module.load (module.js:487:32)
web_1 | at tryModuleLoad (module.js:446:12)
web_1 | at Function.Module._load (module.js:438:3)
web_1 | at Module.require (module.js:497:17)
web_1 | at require (internal/module.js:20:19)
这是package.json:
{
"name": "realaffinities",
"version": "1.0.0",
"description": "",
"main": "server/Server.js",
"keywords": [],
"author": "",
"license": "GPL-3.0",
"dependencies": {
"async": "^2.5.0",
"big-integer": "^1.6.23",
"body-parser": "1.9.0",
"express": "^4.15.3",
"express-validator": "^3.2.1",
"knex": "^0.13.0",
"mysql": "^2.14.1",
"natural": "^0.5.4",
"twit": "^2.2.9",
"url-exists": "^1.0.3",
"nodemon": "^1.11.0"
},
"devDependencies": {
"grunt": "^1.0.1",
"grunt-express-server": "^0.5.3",
"mocha": "^3.4.2",
"supertest": "^3.0.0",
"bcrypt": "1.0.2"
},
"scripts": {
"test": "mocha web-server/test",
"start": "node server/Server.js"
}
}
我的dockerfile:
FROM node:6.11-alpine
EXPOSE 3000
ENV NODE_ENV development
RUN mkdir /app
WORKDIR /app
# add package.json and run npm install before adding the rest of the files
# this way, you only run npm install when package.json changes
ADD /web-server/package.json /app/package.json
RUN apk add --no-cache make gcc g++ python
RUN npm install -g mocha
RUN npm install
我不知道这是一个特定节点包的问题还是我的知识缺乏。如果我在没有docker的Mac上本地运行相同的应用程序,它就不会遇到这个问题。
答案 0 :(得分:6)
有人在this问题中报告了同样的问题,他的案例与您的案例相似。正如评论中所讨论的,这对您有用,所以我也将其作为答案发布:
听起来它正在尝试加载一个不是原生的扩展程序 为linux编译(在容器中) - 也许你以前 在OS X上安装了扩展,并且它正在尝试加载该二进制文件。 如果您的意思是这是一个节点应用程序,请尝试删除node_modules并运行 npm再次安装