运行npm install
时出现以下错误:
npm info it worked if it ends with ok
npm info using npm@2.15.8
npm info using node@v4.4.7
npm ERR! install Couldn't read dependencies
npm ERR! Linux 4.4.15-moby
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
npm ERR! node v4.4.7
npm ERR! npm v2.15.8
npm ERR! path /app/package.json
npm ERR! code ENOPACKAGEJSON
npm ERR! errno -2
npm ERR! syscall open
npm ERR! package.json ENOENT: no such file or directory, open '/app/package.json'
npm ERR! package.json This is most likely not a problem with npm itself.
npm ERR! package.json npm can't find a package.json file in your current directory.
npm ERR! Please include the following file with any support request:
npm ERR! /app/npm-debug.log
这个package.json:
{
"name": "docker_web_app",
"version": "1.0.0",
"description": "Node.js on Docker",
"author": "First Last <first.last@example.com>",
"main": "server.js",
"scripts": {
"start": "node server.js"
},
"dependencies": {
"express": "^4.13.3",
"cassandra-driver": "*"
}
}
我已按照本教程/说明进行操作:https://alexanderzeitler.com/articles/debugging-a-nodejs-es6-application-in-a-docker-container-using-visual-studio-code/
更新:官方docker_hub Node.js是一个MobyLinux,终端非常糟糕。
所以基本上docker run -d -p 3000:3000 -p 5858:5858 hellovscode
与调用npm install
作为参考,Dockerfile:
FROM node:4-onbuild
EXPOSE 3000
EXPOSE 5858
VOLUME /app
WORKDIR /app
RUN cd /app; npm install
CMD ["node", "--debug=5858","index.js"]