使用Node.js初始化和配置AWS
I have downloaded and installed node.js, and now setting up my development environment with my AWS account. Downloading the AWS Javascript SDK looks fine, but I am having a problem initializing my account with it's credentials. After using numerous approaches, it might have to do something with a command line (terminal) configuration? Any suggestions would be appreciated!!
我已下载并安装了node.js,现在使用我的AWS账户设置我的开发环境。下载AWS Javascript SDK看起来很好,但是我在使用它的凭据初始化我的帐户时遇到了问题。使用多种方法后,它可能需要使用命令行(终端)配置?任何建议,将不胜感激!!
Macintosh-27:d3 Examples patrickreynolds$ npm install aws-sdk
npm http GET https://registry.npmjs.org/aws-sdk
npm http 304 https://registry.npmjs.org/aws-sdk
npm http GET https://registry.npmjs.org/xml2js/0.2.4
npm http GET https://registry.npmjs.org/xmlbuilder
npm http 304 https://registry.npmjs.org/xmlbuilder
npm http 304 https://registry.npmjs.org/xml2js/0.2.4
npm http GET https://registry.npmjs.org/sax
npm http 304 https://registry.npmjs.org/sax
aws-sdk@1.5.2 node_modules/aws-sdk
├── xmlbuilder@0.4.2
└── xml2js@0.2.4 (sax@0.5.5)
Macintosh-27:d3 Examples patrickreynolds$ AWS.config.loadFromPath('./config.json');
-bash: syntax error near unexpected token `'./config.json''
Macintosh-27:d3 Examples patrickreynolds$ var AWS = require('aws-sdk');
-bash: syntax error near unexpected token `('
Macintosh-27:d3 Examples patrickreynolds$
My config.json file is saved in both the local director as well as the /node_modules/aws-sdk/config.json directory that is made after installing the AWS SDK. The format in the config.json is as follows:
我的config.json文件保存在本地导向器以及安装AWS SDK后创建的/node_modules/aws-sdk/config.json目录中。 config.json中的格式如下:
{ "accessKeyId": "akid", "secretAccessKey": "secret", "region": "us-west-2" }
The installation process I am following is straight from the Amazon Web Services Javascript documentation page they provide: http://aws.amazon.com/sdkfornodejs/
我所遵循的安装过程直接来自他们提供的Amazon Web Services Javascript文档页面:http://aws.amazon.com/sdkfornodejs/
1 个解决方案
#1
3
Looks like you are attempting to run this directly in a bash shell. You need to either try this in the node repl or write a small node app.
看起来你试图直接在bash shell中运行它。您需要在节点repl中尝试此操作或编写一个小节点应用程序。
Write a quick test.js
file that looks like this and place it in the root of your project:
编写一个看起来像这样的快速test.js文件并将其放在项目的根目录中:
var AWS = require('aws-sdk');
var util = require('util');
AWS.config.loadFromPath('./config.json');
console.log(util.inspect(AWS.config));
Then run it with node:
然后用节点运行它:
node test.js
更多相关文章
- JS获取文件名的方法
- 使用Jquery Ajax更改按钮的颜色(从外部PHP文件接收颜色)
- jQuery Slimbox没有正确请求文件
- 利用javascript实现遍历xml文件的代码实例
- 使用jQuery导出JSON(外部文件)导入数据的度假输出
- JQuery纯前端导入Excel文件,兼容IE10及IE9版本以下浏览器处理方法
- 根据AngularJS中的条件制作输入类型文件[duplicate]
- 如何使用django从静态文件加载静态文件?
- 没有AJAX的拖放文件上传,在前台同步?