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

更多相关文章

  1. JS获取文件名的方法
  2. 使用Jquery Ajax更改按钮的颜色(从外部PHP文件接收颜色)
  3. jQuery Slimbox没有正确请求文件
  4. 利用javascript实现遍历xml文件的代码实例
  5. 使用jQuery导出JSON(外部文件)导入数据的度假输出
  6. JQuery纯前端导入Excel文件,兼容IE10及IE9版本以下浏览器处理方法
  7. 根据AngularJS中的条件制作输入类型文件[duplicate]
  8. 如何使用django从静态文件加载静态文件?
  9. 没有AJAX的拖放文件上传,在前台同步?

随机推荐

  1. 【android 自动化测试】Testing和Instrum
  2. android 一个app启动另一个App的几种方法
  3. Android调用系统, 任意比例裁剪图片
  4. Android 之ActivityThead、ActivityManag
  5. 获取Android设备上的详细的摄像头信息
  6. ListView setOnItemClickListener无效原
  7. Android笔记二十三.Android基于事件监听
  8. Bitmap and DrawPoint
  9. Android笔试(一)
  10. Android 学习笔记1:基本架构