AWS Linux,Docker容器获取npm启动

时间:2017-11-28 12:54:16

标签: javascript node.js docker amazon-ec2 npm

尝试在一个节点上运行docker并运行我的javascript应用程序。

发现此AWS文章安装npm: http://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/setting-up-node-on-ec2-instance.html

执行以下命令:

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.6/install.sh | bash
. ~/.nvm/nvm.sh
nvm install 6.11.5
node -e "console.log('Running Node.js ' + process.version)"

然后开始按照本指南创建要测试的应用: https://medium.com/@sunnykay/docker-development-workflow-node-express-mongo-4bb3b1f7eb1e

我跑了:

npm init
npm install --save express
npm install --save nodemon
touch app.js
nano app.js

#contents of app.js

var express = require('express');
var app = express();
app.get('/', function(req, res){
  res.send("Hello World");
});
app.listen(3000, function(){
  console.log('Example app listening on port 3000!');
});
# add the following to package.json scripts section
"scripts": {
    "start": "nodemon app.js"
  },

我得到的错误低于......

npm start
npm ERR! Linux 4.9.62-21.56.amzn1.x86_64
npm ERR! argv "/home/ec2-user/.nvm/versions/node/v6.11.5/bin/node" "/home/ec2-user/.nvm/versions/node/v6.11.5/bin/npm" "start"
npm ERR! node v6.11.5
npm ERR! npm  v3.10.10

npm ERR! missing script: start
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

npm ERR! Please include the following file with any support request:
npm ERR!     /home/ec2-user/docker-node-mongo/npm-debug.log

0 个答案:

没有答案