nodemon を使用して、React Native アプリで hello world の例を開始しています。しかし、 「npm run dev」を実行すると「babel-node」コマンドを認識しないため、アプリがクラッシュし続けます。エラー出力は次のとおりです。
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `babel-node src`
"babel-node" is not recognized as an internal or external command,
operable program or batch file.
[nodemon] app crashed - waiting for file changes before starting...
このエラーをどのように修正しますか?
私のpackage.json:
{
"name": "frontend",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"build": "babel src -d dist",
"dev": "nodemon src --exec babel-node"
},
"keywords": [],
"dependencies": {
"@babel/plugin-proposal-class-properties": "^7.16.0",
"@babel/plugin-proposal-private-property-in-object": "^7.16.0",
"@react-native-community/masked-view": "^0.1.11",
"@react-navigation/native": "^6.0.6",
"@react-navigation/stack": "^6.0.11",
"cors": "^2.8.5",
"dotenv": "^10.0.0",
"express": "^4.17.1",
"morgan": "^1.10.0",
"mysql2": "^2.3.3",
"native-base": "^3.2.1",
"radio-buttons-react-native": "^1.0.4",
"react": "17.0.1",
"react-dom": "17.0.1",
"react-native": "^0.64.2",
"react-native-animatable": "^1.3.3",
"react-native-dropdown-picker": "^5.1.21",
"react-native-gesture-handler": "^1.10.3",
"react-navigation": "^4.4.4",
"react-navigation-shared-element": "^3.1.3",
"react-navigation-stack": "^2.10.4",
"styled-components": "^5.3.3",
"styled-system": "^5.1.5",
"swagger-jsdoc": "^6.1.0",
"swagger-ui-express": "^4.2.0"
},
"devDependencies": {
"@babel/cli": "^7.16.0",
"@babel/core": "^7.16.0",
"@babel/node": "^7.16.0",
"@babel/plugin-proposal-private-methods": "^7.16.0",
"@babel/preset-env": "^7.16.4",
"@babel/register": "^7.16.0",
"babel-core": "^7.0.0-bridge.0",
"nodemon": "^2.0.15"
},
"private": true
}
私のindex.js(srcフォルダー内:src/index.js):
const greet = 'hello world'
console.log(greet)
私の .babelrc アーカイブ:
{
"presets":[
// "@babel/preset-env"
["@babel/preset-env", { "loose": true }]
],
"plugins": [
["@babel/plugin-proposal-class-properties", { "loose": true }],
["@babel/plugin-proposal-private-methods", { "loose": true }],
["@babel/plugin-proposal-private-property-in-object", { "loose": true }]
]
}
まず第一に、ありがとう