尝试按照本教程手动设置将AWSAmplify
与 S3 存储结合使用。我创建了一个文件如下:amplify-test.js
// import Amplify from 'aws-amplify';
var Amplify = require('aws-amplify');
console.log(Amplify)
Amplify.configure({
Auth: {
// REQUIRED - Amazon Cognito Identity Pool ID
identityPoolId: 'my identity pool id',
// REQUIRED - Amazon Cognito Region
region: 'region',
// OPTIONAL - Amazon Cognito User Pool ID
userPoolId: 'my user pool id',
// OPTIONAL - Amazon Cognito Web Client ID
userPoolWebClientId: 'XX-XXXX-X_abcd1234',
},
Storage: {
bucket: 's3 bucket', //REQUIRED - Amazon S3 bucket
region: 'XX-XXXX-X', //OPTIONAL - Amazon service region
}
});
Amplify.Storage.put('test.txt', 'Hello')
.then (result => console.log(result))
.catch(err => console.log(err));
但是当我运行时node amplify-test.js
,出现以下错误:
放大.configure({ ^
TypeError:Amplify.configure 不是 Object 的函数。(C:\Users\Xiaoyun\VuePwa\aws-cognito-amplify-test\src\amplify-test.js:6:9) 在 Module._compile (internal/modules/cjs/loader.js:702:30) 在Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10) 在 Module.load (internal/modules/cjs/loader.js:612:32) 在 tryModuleLoad (internal/modules/cjs /loader.js:551:12) 在 Function.Module._load (internal/modules/cjs/loader.js:543:3) 在 Function.Module.runMain (internal/modules/cjs/loader.js:744:10 ) 在 bootstrapNodeJSCore (internal/bootstrap/node.js:572:3) 启动时 (internal/bootstrap/node.js:238:19)
我已经aws-amplify
通过运行安装了npm install aws-amplify --save
. 我究竟做错了什么?