I'm trying to update the dependencies of a React app. This app includes a script defined in package.json which generates a message bundle for each locale.
"scripts": {
"build:langs": "NODE_ENV=production babel-node scripts/mergeMessages.js"
}
The details of the script are unimportant, but it's very similar to this one, which is described in a react-intl tutorial.
Before upgrading the dependencies, the script worked, but now when I execute npm run build:langs on the command-line, I get this error:
/applications/my-app/scripts/mergeMessages.js:1
import _objectSpread from "/applications/my-app/node_modules/babel-preset-react-app/node_modules/@babel/runtime/helpers/esm/objectSpread";
^^^^^^^^^^^^^
SyntaxError: Unexpected identifier
at Module._compile (internal/modules/cjs/loader.js:703:23)
at Module._compile (/applications/my-app/node_modules/pirates/lib/index.js:99:24)
at Module._extensions..js (internal/modules/cjs/loader.js:770:10)
at Object.newLoader [as .js] (/applications/my-app/node_modules/pirates/lib/index.js:104:7)
at Module.load (internal/modules/cjs/loader.js:628:32)
at Function.Module._load (internal/modules/cjs/loader.js:555:12)
at Function.Module.runMain (internal/modules/cjs/loader.js:824:10)
at Object.<anonymous> (/applications/my-app/node_modules/@babel/node/lib/_babel-node.js:234:23)
at Module._compile (internal/modules/cjs/loader.js:759:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:770:10)
I guess the babel dependencies are the most relevant. Before the upgrade these were:
"babel-core": "6.26.0",
"babel-eslint": "7.2.3",
"babel-loader": "7.1.2",
"babel-plugin-react-intl": "2.4.0",
"babel-preset-react-app": "3.1.2",
"babel-cli": "6.26.0",
Following the upgrade, the babel dependencies are:
"@babel/core": "7.4.4",
"@babel/polyfill": "7.4.4",
"@babel/register": "7.4.4",
"babel-eslint": "10.0.1",
"babel-loader": "8.0.5",
"babel-plugin-named-asset-import": "^0.3.2",
"babel-preset-react-app": "^8.0.0",
"babel-plugin-react-intl": "2.4.0",
"@babel/cli": "~7.4.4",
"@babel/node": "7.2.2",
Update
I don't have either a .babelrc or babel.config.js config file, just the following in package.json
"babel": {
"presets": [
"react-app"
]
}
create-react-appbut you're not running it increate-react-app. It's only designed for that specific usecase.