I'm getting an error on the start mand when using react-native. The file projectName/node_modules/@babel/core/lib/transformation/file/file.js on line 63 is giving the error
constructor(options, {
^
SyntaxError: Unexpected token {
at exports.runInThisContext (vm.js:53:16)
at Module._pile (module.js:374:25)
at Module._extensions..js (module.js:417:10)
at Object.require.extensions.(anonymous function) [as .js] (/home/cread/WHOOP-ReactNative/whoopApp/node_modules/babel-register/lib/node.js:152:7)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/home/cread/WHOOP-ReactNative/whoopApp/node_modules/@babel/core/lib/index.js:123:36)
at Module._pile (module.js:410:26)
Here is my package.json file
{
"name": *name*,
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"react": "16.3.0-alpha.2",
"react-native": "0.54.2",
"react-native-elements": "^0.19.1",
"react-native-keyboard-aware-scroll-view": "^0.5.0",
"react-native-modal-dropdown": "^0.6.2",
"react-native-sound": "0.10.9",
"react-native-vector-icons": "^4.5.0",
"react-navigation": "^1.5.8"
},
"devDependencies": {
"babel-jest": "23.0.0-alpha.0",
"babel-preset-react-native": "4.0.0",
"jest": "22.4.2",
"react-test-renderer": "16.3.0-alpha.2"
},
"jest": {
"preset": "react-native"
}
}
I've tried deleting my node_modules file, clearing the npm cache, and reinstalling but to no avail. The problem seems to be in the cli.js file.
I'm getting an error on the start mand when using react-native. The file projectName/node_modules/@babel/core/lib/transformation/file/file.js on line 63 is giving the error
constructor(options, {
^
SyntaxError: Unexpected token {
at exports.runInThisContext (vm.js:53:16)
at Module._pile (module.js:374:25)
at Module._extensions..js (module.js:417:10)
at Object.require.extensions.(anonymous function) [as .js] (/home/cread/WHOOP-ReactNative/whoopApp/node_modules/babel-register/lib/node.js:152:7)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/home/cread/WHOOP-ReactNative/whoopApp/node_modules/@babel/core/lib/index.js:123:36)
at Module._pile (module.js:410:26)
Here is my package.json file
{
"name": *name*,
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"react": "16.3.0-alpha.2",
"react-native": "0.54.2",
"react-native-elements": "^0.19.1",
"react-native-keyboard-aware-scroll-view": "^0.5.0",
"react-native-modal-dropdown": "^0.6.2",
"react-native-sound": "0.10.9",
"react-native-vector-icons": "^4.5.0",
"react-navigation": "^1.5.8"
},
"devDependencies": {
"babel-jest": "23.0.0-alpha.0",
"babel-preset-react-native": "4.0.0",
"jest": "22.4.2",
"react-test-renderer": "16.3.0-alpha.2"
},
"jest": {
"preset": "react-native"
}
}
I've tried deleting my node_modules file, clearing the npm cache, and reinstalling but to no avail. The problem seems to be in the cli.js file.
Share Improve this question asked May 23, 2018 at 18:54 Cread DotsonCread Dotson 1,0921 gold badge9 silver badges18 bronze badges1 Answer
Reset to default 6I was using the last version of the react-native and nodejs. Unfortunately, I needed to go back to the version 8.11.2. In my case, it is resolved. I removed the node_modules dir.
$ rm -rf node_modules
$ nvm install 8.11.2
$ nvm use 8.11.2
$ npm install [email protected]