Я получаю эту ошибку при запуске приложения ReactJs в локальной системе. Это приложение используется для создания chrome расширения.
Ошибка на терминале
../common/src/utils/index.ts 1:23
Module parse failed: Unexpected token (1:23)
You may need an appropriate loader to handle this file type.
> export const delay = (t: number) => new Promise((resolve) => setTimeout(resolve, t));
|
| export const recurce = (f: Function, timeout: number) => setTimeout(() => f(), timeout);
Ошибка на chrome консоли
0.chunk.js:78512 ../common/src/utils/states.ts 4:7
Module parse failed: Unexpected token (4:7)
You may need an appropriate loader to handle this file type.
| const UsaStates = require('usa-states').UsaStates;
|
> export interface IUSAState {
| abbreviation: string;
| name: string;
console.<computed> @ 0.chunk.js:78512
пакета. json
{
"name": "extention",
"version": "0.1.0",
"private": true,
"dependencies": {
"@material-ui/core": "^3.9.2",
"@types/jest": "24.0.7",
"@types/node": "11.9.5",
"@types/react": "16.8.5",
"@types/react-dom": "16.8.2",
"axios": "^0.18.0",
"country-json": "^1.0.8",
"jwt-decode": "^2.2.0",
"react": "^16.8.3",
"react-dom": "^16.8.3",
"react-jss": "^8.6.1",
"typeface-roboto": "0.0.54",
"typescript": "3.3.3333",
"usa-states": "0.0.5"
},
"scripts": {
"start": "react-scripts start",
"build": "node ./scripts/build-non-split.js",
"test": "react-scripts test",
"eject": "react-scripts eject",
"web:build": "env-cmd --use-shell 'web-ext build'",
"preweb:build": "npm run build"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
],
"devDependencies": {
"@types/chrome": "0.0.86",
"@types/jwt-decode": "^2.2.1",
"@types/react-jss": "^8.6.3",
"env-cmd": "^10.0.1",
"react-scripts": "^2.1.5",
"rewire": "^4.0.1",
"web-ext": "^4.0.0"
}
}
tsconfig. json
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "preserve"
},
"include": [
"src"
]
}
ПРИМЕЧАНИЕ. Я нашел много ответов, связанных с этой ошибкой, но, похоже, все они связаны с babel
, но babel
отсутствует в моем пакете. json