javascript - 试用 AWS-Amplify ->“npm start”不起作用
问题描述
为了更好地了解如何使用,AWS-Amplify
我正在关注此文档。
一切顺利,直到我到达修改 src/app.js 后我想运行此命令的点(步骤 4. Integrate AWS Resources ):
$ npm start
然后希望(在浏览器中)查看:
http://localhost:8080/
但这是运行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.
......
$
因为这里没有我自己的代码,只有我从上面链接的文档中得到的。我猜其他人在某些时候也遇到了同样的问题。
我能做些什么来解决这个问题吗?(谁都知道)
仅供参考,这里是./src/app.js的内容,从上面提到的链接复制:
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>';
});
解决方案
推荐阅读
- c++ - 反转 18 位 int 的二进制补码
- jquery - jquery函数,如果跨度存在
- javascript - 为什么图像没有转换成base64?
- bash - 每次打开程序预览弹出一张图片-bash命令
- python - 使用 pint 获取特定维度的所有单位
- mongodb - mongodb 对其他字段进行分组和计数、匹配和更新
- c# - 对象数组中的对象数组
- python - 在两个分隔符之间找到标记 - 不和谐的表情
- sqlite - ServiceStack Ormlite 发出 Sqlite 特定命令
- ibm-cloud - Mac High Sierra 和 Zsh 上的 IBM Cloud CLI 自动完成?