エラー内容
expo start --ios
コマンドで iOS シミュレータの Expo Client を起動すると、
コンソール上にエラーは出ないのですが、シミュレータの画面上に下記のエラーが出てアプリケーションが起動できません。
Unhandled JS Exception: Unexpected token '{'. import call expects exactly one argument.
(http://127.0.0.1:19001/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&minify=false&hot=false&assetPlugin={プロジェクトのパス}%2Fnode_modules%2Fexpo%2Ftools%2FhashAssetFiles.js:1808)
JavaScript → TypeScript のコンバート作業の中で遭遇したエラーです(TypeScript のコンパイルは通っている)
tsファイルのimport部分の文法を疑いましたが、ESlintなども入れていて警告などは出ていません。
babel や tsconfig の設定に不備などはありますでしょうか?
試したこと
とりあえず、キャッシュ削除や node_modules の入れ直しなどを行いましたが解決しません。
$ npm cache verify
$ watchman watch-del-all
$ rm -rf /tmp/metro-bundler-cache-*
$ rm -rf /tmp/haste-map-react-native-packager-*
$ rm -rf node_modules && npm i
$ expo start -c
プロジェクト詳細
- ディレクトリ構成
project
├── App.js
├── README.md
├── node_modules
│ ├── ...
├── __tests__
│ └── ...
├── app.json
├── assets
│ ├── ...
├── constants
│ ├── ...
├── .babelrc
├── .env
├── .eslintignore
├── .eslintrc.js
├── .expo
│ ├── ...
├── .expo-shared
│ ├── ...
├── .gitignore
├── .stylelintrc.js
├── .vscode
│ ├── ...
├── .watchmanconfig
├── package-lock.json
├── package.json
├── src
│ ├── ... (tsファイル群)
└── tsconfig.json
.babelrc
{
"presets": [
["@babel/preset-env", { "modules": false }],
["@babel/preset-react", { "modules": false }],
["@babel/preset-typescript", { "modules": false }]
],
"plugins": [
"@babel/plugin-transform-typescript",
"@babel/plugin-proposal-class-properties",
"@babel/plugin-proposal-export-default-from",
["@babel/plugin-proposal-decorators", { "legacy": true }]
]
}
tsconfig.json
{
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "commonjs",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-native",
"baseUrl": ".",
"paths": {
"app/*": ["./*"]
},
"experimentalDecorators": true
},
"include": ["src"],
"exclude": ["node_modules"]
}
package.json
(余計なものが色々入ってますが...><)
{
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"eject": "expo eject",
"test": "node ./node_modules/jest/bin/jest.js --watchAll"
},
"jest": {
"preset": "jest-expo"
},
"dependencies": {
"@expo/samples": "2.1.1",
"@types/expo": "^32.0.0",
"@types/react": "^16.8.19",
"@types/react-native": "^0.57.60",
"@types/react-native-datepicker": "^1.7.0",
"@types/react-native-vector-icons": "^6.4.0",
"@types/react-navigation": "^3.0.7",
"@types/react-navigation-material-bottom-tabs": "^0.3.1",
"@types/react-redux": "^7.0.9",
"axios": "^0.19.0",
"dotenv": "^8.0.0",
"expo": "^32.0.0",
"native-base": "^2.12.1",
"react": "16.5.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-32.0.0.tar.gz",
"react-native-datepicker": "^1.7.2",
"react-native-elements": "^1.0.0",
"react-native-material-ui": "^1.30.1",
"react-native-paper": "^2.16.0",
"react-native-typescript-transformer": "^1.2.12",
"react-native-vector-icons": "^6.4.2",
"react-navigation": "^3.0.9",
"react-navigation-material-bottom-tabs": "^1.0.0",
"react-navigation-redux-helpers": "^3.0.2",
"react-navigation-tabs": "^0.8.4",
"react-redux": "^5.0.7",
"redux": "^4.0.0",
"typescript": "^3.4.5"
},
"devDependencies": {
"@babel/core": "^7.4.5",
"@babel/plugin-proposal-class-properties": "^7.4.4",
"@babel/plugin-proposal-export-default-from": "^7.2.0",
"@babel/plugin-transform-typescript": "^7.4.5",
"@babel/preset-env": "^7.4.5",
"@babel/preset-react": "^7.0.0",
"@babel/preset-typescript": "^7.3.3",
"@babel/register": "^7.4.4",
"@babel/runtime": "^7.4.5",
"@typescript-eslint/eslint-plugin": "^1.9.0",
"@typescript-eslint/parser": "^1.9.0",
"babel-core": "^6.26.3",
"babel-eslint": "^10.0.1",
"babel-loader": "^8.0.6",
"babel-preset-es2015": "^6.24.1",
"babel-preset-expo": "^5.0.0",
"babel-preset-react": "^6.24.1",
"babel-preset-react-native": "^4.0.1",
"babel-preset-typescript": "^7.0.0-alpha.19",
"eslint": "^5.16.0",
"eslint-config-airbnb": "^17.1.0",
"eslint-config-prettier": "^4.3.0",
"eslint-plugin-import": "^2.17.2",
"eslint-plugin-jest": "^22.6.4",
"eslint-plugin-jsx-a11y": "^6.2.1",
"eslint-plugin-prettier": "^3.1.0",
"eslint-plugin-react": "^7.13.0",
"eslint-plugin-react-hooks": "^1.6.0",
"husky": "^2.3.0",
"jest-expo": "^33.0.0",
"lint-staged": "^8.1.7",
"prettier": "^1.17.1",
"prettier-stylelint": "^0.4.2",
"stylelint": "^10.0.1",
"stylelint-config-prettier": "^5.2.0",
"stylelint-config-standard": "^18.3.0",
"stylelint-order": "^3.0.0",
"ts-loader": "^6.0.2",
"webpack": "^4.32.2",
"webpack-cli": "^3.3.2",
"webpack-dev-server": "^3.5.0"
},
"private": true,
"name": "app"
}
- npm バージョン
6.9.0