At the moment I'm working on a React and React Native app. They both use the same database so I decided to create another project just for that database so both projects can use the same files without me having to change it in 2 separate projects. I added that project as a package with npm i --save [link]
. It works as expected. Can also use its exports inside the React app.
When starting the app I get this error:
ERROR in ./node_modules/common/database/index.ts 5:7
Module parse failed: Unexpected token (5:7)
File was processed with these loaders:
* ./node_modules/source-map-loader/dist/cjs.js
You may need an additional loader to handle the result of these loaders.
| import logger from "../util/logger";
|
> export enum DatabaseBackend {
| Admin,
| ReactNative,
ERROR in ./node_modules/common/repositories/booking.ts 5:57
Module parse failed: Unexpected token (5:57)
File was processed with these loaders:
* ./node_modules/source-map-loader/dist/cjs.js
You may need an additional loader to handle the result of these loaders.
| import { Nanny, Parent } from "../types/user.type";
|
> const toBookingList = bookings => bookings.map(([ b, id ]: [ DTOBooking, string ]) => toBooking(b, id));
I checked this post because he seems to have had a similar issue. So I changed my tsconfig.json
from
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
// ...
}
to:
"compilerOptions": {
"target": "ES6",
"lib": ["DOM", "ES6", "DOM.Iterable", "ScriptHost", "ES2016.Array.Include"],
// ...
}
However the project still won't start. Should I compile the database project into JS instead of TS before using it? Any help would be appreciated.