Reputation: 121
I am facing the following error while building on AWS amplify:
Syntax error: Cannot read property 'map' of undefined (0:undefined)
Here is my code:
import React from 'react';
import ReactDOM from 'react-dom';
export default class BusinessHTTPService {
static getBusinessList = () => {
return axios.get(`${API_BASE}business-categories/?`).then(response => response.data);
};
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"></script>
Upvotes: 10
Views: 2919
Reputation: 2965
I had similar issue with this code:
interface Event<EventArgs extends unknown[] = []> { ... }
The problem disappeared when I specified the type of the array:
interface Event<EventArgs extends unknown[] = unknown[]> { ... }
Upvotes: 0
Reputation: 76
I had the same issue with by build failing on AWS Amplify Console, but was fine locally.
How to reproduce locally
I was able to reproduce it locally by following these steps:
"npm start" would fail, and show the error "Line 0: Parsing error: Cannot read property 'map' of undefined".
How to solve
I was able to solve it eventually by following these steps:
I don't see the error anymore, and when I push to AWS Amplify Console, it builds without issues.
Upvotes: 5