试用 AWS-Amplify -> "npm start" 不工作
Trying out AWS-Amplify -> "npm start" not working
为了更好地了解如何使用 AWS-Amplify
我正在关注 this document。
一切顺利,直到我到达(步骤 4. 集成 AWS 资源)修改 src/app.js 后我想 运行 这个命令:
$ npm start
然后希望(在浏览器中)查看:
http://localhost:8080/
但是当 运行ning npm start
时会发生什么
$ npm start
> amplify-js-app@1.0.0 start /Users/myaccount/amplify-js-app
> webpack && webpack-dev-server --mode development
Hash: xyzaghs789
Version: webpack 4.33.0
Time: 116ms
Built at: 06/10/2019 11:03:49 PM
Asset Size Chunks Chunk Names
index.html 1.55 KiB [emitted]
main.bundle.js 28.9 KiB main [emitted] main
Entrypoint main = main.bundle.js
[./src/app.js] 145 bytes {main} [built] [failed] [1 error]
ERROR in ./src/app.js 26:0
Module parse failed: Unexpected token (26:0)
You may need an appropriate loader to handle this file type.
| });
|
>
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! amplify-js-app@1.0.0 start: `webpack && webpack-dev-server --mode development`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the amplify-js-app@1.0.0 start script.
npm ERR! This is probably not a problem with npm.
There is likely additional logging output above.
......
$
因为这里没有我自己的代码,只有我从上面的文档 linked 中得到的代码。
我想其他人在某些时候也遇到过同样的问题。
有什么办法可以解决这个问题吗? (谁知道)
仅供参考,这里是./src/app.js的内容,复制自上述link:
import Auth from '@aws-amplify/auth';
import Analytics from '@aws-amplify/analytics';
import awsconfig from './aws-exports';
// retrieve temporary AWS credentials and sign requests
Auth.configure(awsconfig);
// send analytics events to Amazon Pinpoint
Analytics.configure(awsconfig);
const AnalyticsResult = document.getElementById('AnalyticsResult');
const AnalyticsEventButton = document.getElementById('AnalyticsEventButton');
let EventsSent = 0;
AnaltyicsEventButton.addEventListener('click', (event) => {
const { aws_mobile_analytics_app_region, aws_mobile_analytics_app_id } = awsconfig;
Analytics.record('Amplify Tutorial Event')
.then((event) => {
const url = `https://${aws_mobile_analytics_app_region}.console.aws.amazon.com/pinpoint/home/?region=${aws_mobile_analytics_app_region}#/apps/${aws_mobile_analytics_app_id}/analytics/events`;
AnalyticsResult.innerHTML = '<p>Event Submitted. </p>';
AnalyticsResult.innerHTML += '<p>Events sent: '+(++EventsSent)+'</p>';
AnalyticsResult.innerHTML += '<a href="'+url+'" target="_blank">View Events on the Amazon Pinpoint Console</a>';
});
以防其他人碰巧遇到同样的问题。
这(花括号和括号):
});
./src/app.js 末尾缺失,文件在 document.
为了更好地了解如何使用 AWS-Amplify
我正在关注 this document。
一切顺利,直到我到达(步骤 4. 集成 AWS 资源)修改 src/app.js 后我想 运行 这个命令:
$ npm start
然后希望(在浏览器中)查看:
http://localhost:8080/
但是当 运行ning npm start
时会发生什么$ npm start
> amplify-js-app@1.0.0 start /Users/myaccount/amplify-js-app
> webpack && webpack-dev-server --mode development
Hash: xyzaghs789
Version: webpack 4.33.0
Time: 116ms
Built at: 06/10/2019 11:03:49 PM
Asset Size Chunks Chunk Names
index.html 1.55 KiB [emitted]
main.bundle.js 28.9 KiB main [emitted] main
Entrypoint main = main.bundle.js
[./src/app.js] 145 bytes {main} [built] [failed] [1 error]
ERROR in ./src/app.js 26:0
Module parse failed: Unexpected token (26:0)
You may need an appropriate loader to handle this file type.
| });
|
>
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! amplify-js-app@1.0.0 start: `webpack && webpack-dev-server --mode development`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the amplify-js-app@1.0.0 start script.
npm ERR! This is probably not a problem with npm.
There is likely additional logging output above.
......
$
因为这里没有我自己的代码,只有我从上面的文档 linked 中得到的代码。 我想其他人在某些时候也遇到过同样的问题。
有什么办法可以解决这个问题吗? (谁知道)
仅供参考,这里是./src/app.js的内容,复制自上述link:
import Auth from '@aws-amplify/auth';
import Analytics from '@aws-amplify/analytics';
import awsconfig from './aws-exports';
// retrieve temporary AWS credentials and sign requests
Auth.configure(awsconfig);
// send analytics events to Amazon Pinpoint
Analytics.configure(awsconfig);
const AnalyticsResult = document.getElementById('AnalyticsResult');
const AnalyticsEventButton = document.getElementById('AnalyticsEventButton');
let EventsSent = 0;
AnaltyicsEventButton.addEventListener('click', (event) => {
const { aws_mobile_analytics_app_region, aws_mobile_analytics_app_id } = awsconfig;
Analytics.record('Amplify Tutorial Event')
.then((event) => {
const url = `https://${aws_mobile_analytics_app_region}.console.aws.amazon.com/pinpoint/home/?region=${aws_mobile_analytics_app_region}#/apps/${aws_mobile_analytics_app_id}/analytics/events`;
AnalyticsResult.innerHTML = '<p>Event Submitted. </p>';
AnalyticsResult.innerHTML += '<p>Events sent: '+(++EventsSent)+'</p>';
AnalyticsResult.innerHTML += '<a href="'+url+'" target="_blank">View Events on the Amazon Pinpoint Console</a>';
});
以防其他人碰巧遇到同样的问题。 这(花括号和括号):
});
./src/app.js 末尾缺失,文件在 document.