I just upgraded from RN 0.55.4 to 0.59.3.....now Im getting following error:
Error: Unable to resolve module metro/src/lib/bundle-modules/HMRClient from ....\node_modules\react-native\Libraries\Utilities\HMRClient.js: Module metro/src/lib/bundle-modules/HMRClient does not exist in the Haste module map
The HMRClient.js file does include the following require statement: const MetroHMRClient = require('metro/src/lib/bundle-modules/HMRClient');.....and I cant see that path beginning with 'metro' anywhere so I guess I need to add it somehow. There is also another require statement as follows: const invariant = require('invariant'); ....no file name 'invariant' exists either.
Facebook say this was fixed back in 0.53.0 master but looks like its back
https://github.com/facebook/react-native/issues/17742
Below is my package.json
{
"name": "xs",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest",
"flow": "flow",
"flow start": "flow start",
"flow stop": "flow stop",
"flow status": "flow status",
"flow coverage": "flow coverage"
},
"dependencies": {
"firebase": "^5.11.1",
"flow": "^0.2.3",
"flow-bin": "^0.65.0",
"prop-types": "^15.6.1",
"react": "16.8.3",
"react-native": "0.59.3",
"react-native-elements": "^0.19.0",
"react-native-google-places-autocomplete": "^1.3.9",
"react-native-maps": "git://github.com/react-native-community/react-native-maps.git#master",
"react-native-switch": "^1.4.0",
"react-native-vector-icons": "^4.5.0",
"react-navigation": "^2.5.5",
"react-redux": "^5.1.0",
"redux": "^4.0.1",
"redux-thunk": "^2.3.0"
},
"devDependencies": {
"babel-eslint": "^8.2.6",
"babel-preset-flow": "^6.23.0",
"eslint": "^4.9.0",
"eslint-config-airbnb": "^16.1.0",
"eslint-plugin-import": "^2.17.3",
"eslint-plugin-jsx-a11y": "^6.2.1",
"eslint-plugin-react": "^7.13.0",
"prettier-eslint": "^8.8.2",
"#babel/core": "^7.4.3",
"#babel/runtime": "^7.4.3",
"babel-jest": "^24.7.1",
"jest": "^24.7.1",
"metro-react-native-babel-preset": "^0.53.1",
"react-test-renderer": "16.8.3"
},
"jest": {
"preset": "react-native"
}
}
Please help!
p.s. the below suggestion does not work
To resolve try the following:
1. Clear watchman watches: watchman watch-del-all.
2. Delete the node_modules folder: rm -rf node_modules && npm install.
3. Reset Metro Bundler cache: rm -rf /tmp/metro-bundler-cache-* or npm start -- --reset-cache.
4. Remove haste cache: rm -rf /tmp/haste-map-react-native-packager-*.
Pay attention when running npm install to see if there is any need for a specific version of something.
First check babel config files then if it doesn't work try the changes in package.json.
Try config files and deps as below.
This is a config that worked for me for an update from 0.54 to 0.59.5:
package.json:
" dependencies": {
"react": "16.8.3",
"react-native": "0.59.5",
// ...
},
"devDependencies": {
"#babel/core": "^7.0.0-0",
"babel-core": "^7.0.0-bridge.0",
"metro-react-native-babel-preset": "0.53.0",
"react-test-renderer": "16.6.3",
// ...
}
babel.config.js:
module.exports = {
presets: ['module:metro-react-native-babel-preset'],
};
.babelrc:
{
"presets": ["module:metro-react-native-babel-preset"]
}
The only useful info I could find in the RN release notes about babel and metro changes was at [0.57] here:
https://github.com/react-native-community/releases/blob/master/CHANGELOG.md
UPDATE NOTE:
Trying config files as the ones from a new working project (created with 0.59.9) doesn't seem to work for an update from 0.54 to 0.59
babel.config.js:
module.exports = {
presets: ['module:metro-react-native-babel-preset'],
};
metro.config.js:
module.exports = {
transformer: {
getTransformOptions: async () => ({
transform: {
experimentalImportSupport: false,
inlineRequires: false,
},
}),
},
};
and no .babelrc file.
package.json:
"devDependencies": {
"#babel/core": "^7.4.5",
"#babel/runtime": "^7.4.5",
"metro-react-native-babel-preset": "^0.54.1",
},
Related
I get the following error when I want to build my APK.
Export namespace should be first transformed by
#babel/plugin-proposal-export-namespace-from
I need to say that I have imported react-native-gesture-handler in the index.js
and this is my index.js
import 'react-native-gesture-handler';
import {AppRegistry} from 'react-native';
import App from './app/App';
import {name as appName} from './app.json';
import { LogBox } from 'react-native';
LogBox.ignoreAllLogs();
AppRegistry.registerComponent(appName, () => App);
during development mode, I did not get that error.
this is my package.json
{
"name": "blackout",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint ."
},
"dependencies": {
"#react-native-async-storage/async-storage": "^1.17.6",
"#react-native-community/geolocation": "^2.1.0",
"#react-native-community/netinfo": "^9.0.0",
"#react-native-community/viewpager": "^5.0.11",
"#react-navigation/bottom-tabs": "^6.3.1",
"#react-navigation/native": "^6.0.10",
"#react-navigation/native-stack": "^6.6.2",
"#react-navigation/stack": "^6.2.1",
"axios": "^0.27.2",
"es6-template-strings": "^2.0.1",
"jalali-moment": "^3.3.11",
"jwt-decode": "^3.1.2",
"react": "17.0.2",
"react-hook-form": "^7.32.2",
"react-native": "0.68.2",
"react-native-android-open-settings": "^1.3.0",
"react-native-audio-recorder-player": "^3.5.1",
"react-native-device-info": "^9.0.2",
"react-native-element-dropdown": "^2.0.0",
"react-native-fs": "^2.20.0",
"react-native-gesture-handler": "^2.4.2",
"react-native-image-crop-picker": "^0.37.3",
"react-native-image-picker": "^4.8.4",
"react-native-modal": "^13.0.1",
"react-native-reanimated": "^2.9.1",
"react-native-safe-area-context": "^4.3.1",
"react-native-screens": "^3.13.1",
"react-native-size-matters": "^0.4.0",
"react-native-snackbar": "^2.4.0",
"react-native-tab-view": "^3.1.1",
"react-native-vector-icons": "^9.1.0",
"react-native-video": "^5.2.0",
"react-native-webview": "^11.22.2",
"react-redux": "^8.0.2",
"realm": "10.19.5",
"redux": "^4.2.0",
"redux-thunk": "^2.4.1",
"rn-fetch-blob": "^0.12.0"
},
"devDependencies": {
"#babel/code-frame": "^7.16.7",
"#babel/core": "^7.12.9",
"#babel/runtime": "^7.12.5",
"#react-native-community/eslint-config": "^2.0.0",
"babel-jest": "^26.6.3",
"eslint": "^7.32.0",
"jest": "^26.6.3",
"metro-react-native-babel-preset": "^0.67.0",
"react-test-renderer": "17.0.2"
},
"jest": {
"preset": "react-native"
}
}
I really appreciate any help you can provide.
You have to add the 'react-native-reanimated/plugin' to the plugins array.
make sure this Plugin should be the last.
open the babel.config.js in the root of your project and modify it as follow:
module.exports = {
presets: ['module:metro-react-native-babel-preset'],
plugins: [
...
'react-native-reanimated/plugin', // This line.
],
};
NOTE: After adding the react-native-reanimated/plugin to your project you may encounter a false-positive "Reanimated 2 failed to create a worklet" error. In most cases, this can be fixed by cleaning the application's cache. Depending on your workflow or favourite package manager that could be done by:
yarn start --reset-cache
npm start -- --reset-cache
expo start -c
For more information
Your babel.config.js should look like
module.exports = {
presets: ['module:metro-react-native-babel-preset'],
plugins: ['react-native-reanimated/plugin'],
};
If you have an Expo managed project, your babel.config.js should be looking like this:
module.exports = function (api) {
api.cache(true);
return {
presets: ["babel-preset-expo"],
plugins: [
"react-native-reanimated/plugin", // This line.
],
};
};
It seems like there was a breaking change between react-native-reanimated 2.9 and 2.12. The latest version doesn't have a reference to #babel/plugin-proposal-export-namespace-from anymore. To solve this I followed examples I found in this commit.
Add this to babel.config.js:
module.exports = {
presets: ['module:metro-react-native-babel-preset'],
plugins: [
...
'react-native-reanimated/plugin',
'#babel/plugin-proposal-export-namespace-from',
],
};
Then run these commands:
yarn add #babel/plugin-proposal-export-namespace-from
yarn start -c
Another possible way is to change ts version to "ES2020" in tsconfig.json.
https://babeljs.io/docs/en/babel-plugin-proposal-export-namespace-from
Run these command
yarn add #babel/plugin-proposal-export-namespace-from -D
Then add the item "'#babel/plugin-proposal-export-namespace-from'" in the plugins array of your babel.config.js file
Example of my babel.config.js:
module.exports = function (api) {
api.cache(true)
return {
presets: ['babel-preset-expo'],
plugins: [
'#babel/plugin-proposal-export-namespace-from',
'react-native-reanimated/plugin'
]
}
}
I'm getting this error when trying to run yarn run dev --port=4000
Here is the error:
Module build failed (from ./node_modules/babel-loader/lib/index.js): friendly-errors 16:52:26
Error: /Users/jacob/code/artistrepublik/elite-reviews/.nuxt/client.js: Cannot find module '#babel/preset-env/lib/utils'
Require stack:
- /Users/jacob/code/artistrepublik/elite-reviews/node_modules/#nuxt/babel-preset-app/src/polyfills-plugin.js
- /Users/jacob/code/artistrepublik/elite-reviews/node_modules/#nuxt/babel-preset-app/src/index.js
- /Users/jacob/code/artistrepublik/elite-reviews/node_modules/#babel/core/lib/config/files/module-types.js
- /Users/jacob/code/artistrepublik/elite-reviews/node_modules/#babel/core/lib/config/files/configuration.js
- /Users/jacob/code/artistrepublik/elite-reviews/node_modules/#babel/core/lib/config/files/index.js
- /Users/jacob/code/artistrepublik/elite-reviews/node_modules/#babel/core/lib/index.js
- /Users/jacob/code/artistrepublik/elite-reviews/node_modules/nuxt-route-meta/dist/index.js
- /Users/jacob/code/artistrepublik/elite-reviews/node_modules/#nuxt/core/dist/core.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:965:15)
at Function.Module._load (internal/modules/cjs/loader.js:841:27)
at Module.require (internal/modules/cjs/loader.js:1025:19)
at n (/Users/jacob/code/artistrepublik/elite-reviews/node_modules/jiti/dist/v8cache.js:2:2364)
at PluginPass.Program (/Users/jacob/code/artistrepublik/elite-reviews/node_modules/#nuxt/babel-preset-app/src/polyfills-plugin.js:15:34)
at newFn (/Users/jacob/code/artistrepublik/elite-reviews/node_modules/#babel/traverse/lib/visitors.js:175:21)
at NodePath._call (/Users/jacob/code/artistrepublik/elite-reviews/node_modules/#babel/traverse/lib/path/context.js:55:20)
at NodePath.call (/Users/jacob/code/artistrepublik/elite-reviews/node_modules/#babel/traverse/lib/path/context.js:42:17)
at NodePath.visit (/Users/jacob/code/artistrepublik/elite-reviews/node_modules/#babel/traverse/lib/path/context.js:92:31)
at TraversalContext.visitQueue (/Users/jacob/code/artistrepublik/elite-reviews/node_modules/#babel/traverse/lib/context.js:116:16)
at TraversalContext.visitSingle (/Users/jacob/code/artistrepublik/elite-reviews/node_modules/#babel/traverse/lib/context.js:85:19)
at TraversalContext.visit (/Users/jacob/code/artistrepublik/elite-reviews/node_modules/#babel/traverse/lib/context.js:144:19)
at Function.traverse.node (/Users/jacob/code/artistrepublik/elite-reviews/node_modules/#babel/traverse/lib/index.js:82:17)
at traverse (/Users/jacob/code/artistrepublik/elite-reviews/node_modules/#babel/traverse/lib/index.js:62:12)
at transformFile (/Users/jacob/code/artistrepublik/elite-reviews/node_modules/#babel/core/lib/transformation/index.js:107:29)
at transformFile.next (<anonymous>)
friendly-errors 16:52:26
# multi ./node_modules/eventsource-polyfill/dist/browserify-eventsource.js (webpack)-hot-middleware/client.js?reload=true&timeout=30000&ansiColors=&overlayStyles=&path=%2F__webpack_hmr%2Fclient&name=client ./.nuxt/client.js
Here is my package.json:
{
"name": "my-project",
"version": "1.0.0",
"private": true,
"scripts": {
"dev": "nuxt -r dotenv/config",
"build": "nuxt build",
"start": "nuxt start",
"generate": "nuxt generate",
"test": "jest"
},
"dependencies": {
"#nuxtjs/axios": "^5.12.5",
"#nuxtjs/dotenv": "^1.4.1",
"#nuxtjs/pwa": "^3.3.4",
"#paypal/paypal-js": "^1.0.5",
"#vue/babel-preset-app": "^4.5.10",
"core-js": "^3.8.3",
"es6-promise": "^4.1.1",
"lodash": "^4.17.20",
"moment": "latest",
"moment-timezone": "^0.5.32",
"noty": "^3.2.0-beta",
"nuxt": "^2.14.12",
"nuxt-i18n": "^6.18.0",
"nuxt-route-meta": "^1.0.3",
"nuxt": "^2.14.6",
"nuxt-i18n": "^6.15.1",
"nuxt-route-meta": "^1.0.1",
"nuxt-stripe-module": "^3.0.1",
"object-to-formdata": "^4.1.0",
"pluralize": "latest",
"vee-validate": "^3.4.5",
"sib-api-v3-sdk": "github:sendinblue/APIv3-nodejs-library",
"vue-carousel": "^0.18.0",
"vue-chartist": "^2.2.1",
"vue-material-design-icons": "^4.11.0",
"vuejs-noty": "^0.1.3",
"vue-plyr": "^7.0.0",
"vuetify-media-player": "^0.8.1"
},
"devDependencies": {
"#babel/core": "^7.12.10",
"#mdi/font": "^5.9.55",
"#nuxt/types": "^2.14.12",
"#nuxtjs/style-resources": "^1.0.0",
"#nuxtjs/vuetify": "^1.11.3",
"#vue/test-utils": "^1.1.2",
"babel-jest": "^26.6.3",
"babel-plugin-component": "^1.1.0",
"cross-env": "^5.2.0",
"dotenv": "^8.2.0",
"jest": "^26.6.3",
"material-design-icons-iconfont": "^6.1.0",
"node-sass": "^4.14.1",
"nodemon": "^1.18.9",
"sass-loader": "^7.3.1",
"vue-jest": "^3.0.4"
}
}
And here is my .babelrc:
{
"env": {
"test": {
"presets": [
[
"#babel/preset-env",
{
"targets": {
"node": "current"
}
}
]
]
}
}
}
I have tried deleting the node_modules folder along with removing the yarn.lock file with no luck. The babel version looks correct. This error only popped up after me playing around with some code (not the package.json) - which is an unrelated error.
Any help would be appreciated!
#babel/preset-env updated,
use old version 7.12.17
https://www.npmjs.com/package/#babel/preset-env/v/7.12.17
This issue drove me crazy for a few hours too.
The solution is to add to nuxt.config.js into build section:
/*
** Build configuration
*/
build: {
babel: {
presets(env, [ preset, options ]) {
return [
[ "#babel/preset-env", options ]
]
}
},
Make sure you have that thing installed:
npm install --save-dev #babel/preset-env
or in your case with yarn
Updated:
Then I encountered another error
regeneratorRuntime is not defined
Here is working part from my config.nuxt.js
build: {
babel: {
presets({isServer}) {
const targets = isServer ? { node: 'current' } : { ie: 11 }
return [
[ require.resolve("#babel/preset-env"), { targets } ]
]
},
plugins: [
"#babel/syntax-dynamic-import",
"#babel/transform-runtime",
"#babel/transform-async-to-generator"
]
},
I did the following:
npm uninstall #babel/preset-env
npm install #babel/preset-env#7.12.13
The latest version seems to have this issue resolved, try updating Nuxt to v2.15.2
https://nuxtjs.org/docs/release-notes
lib/utils.js was dropped for #babel/preset-env#7.13.0 and above
as stated above installing the old 7.12.17 might work
for monorepos it may not be enough. upgrading nuxtjs to 2.15.x did the trick for me
I had same error when deploying to ElasticBeanstalk
Error: /var/app/current/.nuxt/client.js: Cannot find module '#babel/preset-env/lib/utils'
upgrading from "nuxt": "v2.14.12", to "nuxt": "v2.15.2", seem to have solved the problem
npm uninstall #babel/preset-env
npm install #babel/preset-env#7.12.17
I just had the same problem, There's some issue with the newest #babel/preset-env within the Nuxt.
install the old version and it should work just fine
npm i #babel/preset-env#7.12.17 -S
You can try to do:
// package.json
"devDependencies": {
+ "#babel/preset-env": "7.12.17",
"cross-env": "^5.2.0",
"css-loader": "^3.2.0",
"node-sass": "^4.14.1",
"sass-loader": "^8.0.2",
"style-loader": "^1.0.0"
},
// package-lock.json
"#babel/preset-env": {
+"version": "7.12.17",
...,
"#nuxt/babel-preset-app": {
"requires": {
"#babel/preset-env": "7.12.17",
...
}
}
}
**> bundling failed: Error: Unable to resolve module
metro/src/lib/bundle-modules/HMRClient from
D:\korero_latest_app\korero_app\node_modules\react-native\Libraries\Utilities\HMRClient.js:
Module metro/src/lib/bundle-modules/HMRClient does not exist in the
Haste module map
This might be related to
https://github.com/facebook/react-native/issues/4968 To resolve try
the following:
1. Clear watchman watches: watchman watch-del-all.
2. Delete the node_modules folder: rm -rf node_modules && npm install.
3. Reset Metro Bundler cache: rm -rf /tmp/metro-bundler-cache-* or npm start -- --reset-cache.
4. Remove haste cache: rm -rf /tmp/haste-map-react-native-packager-*.
at ModuleResolver.resolveDependency (D:\korero_latest_app\korero_app\node_modules#react-native-community\cli\node_modules\metro\src\node-haste\DependencyGraph\ModuleResolution.js:183:15)
at ResolutionRequest.resolveDependency (D:\korero_latest_app\korero_app\node_modules#react-native-community\cli\node_modules\metro\src\node-haste\DependencyGraph\ResolutionRequest.js:52:18)
at DependencyGraph.resolveDependency (D:\korero_latest_app\korero_app\node_modules#react-native-community\cli\node_modules\metro\src\node-haste\DependencyGraph.js:283:16)
at Object.resolve (D:\korero_latest_app\korero_app\node_modules#react-native-community\cli\node_modules\metro\src\lib\transformHelpers.js:261:42)
at dependencies.map.result (D:\korero_latest_app\korero_app\node_modules#react-native-community\cli\node_modules\metro\src\DeltaBundler\traverseDependencies.js:399:31)
at Array.map ()
at resolveDependencies (D:\korero_latest_app\korero_app\node_modules#react-native-community\cli\node_modules\metro\src\DeltaBundler\traverseDependencies.js:396:18)
at D:\korero_latest_app\korero_app\node_modules#react-native-community\cli\node_modules\metro\src\DeltaBundler\traverseDependencies.js:269:33
at Generator.next ()
at asyncGeneratorStep (D:\korero_latest_app\korero_app\node_modules#react-native-community\cli\node_modules\metro\src\DeltaBundler\traverseDependencies.js:87:24)
DELTA [android, dev] ./index.js ▓▓▓▓▓▓▓▓▓▓▓▓░░░░ 76.0% (930/1067),
failed.
::ffff:127.0.0.1 - - [03/Feb/2020:08:51:14 +0000] "GET
/index.delta?platform=android&dev=true&minify=false HTTP/1.1" 500 -
"-" "okhttp/3.12.1"**
package.json:-
{
"name": "korero_app",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"axios": "^0.19.0",
"formik": "^1.5.7",
"lodash": "^4.17.11",
"moment": "^2.24.0",
"react": "16.8.3",
"react-native": "0.59.9",
"react-native-action-button": "^2.8.5",
"react-native-elements": "^1.1.0",
"react-native-floating-action": "^1.17.0",
"react-native-gesture-handler": "^1.3.0",
"react-native-material-textfield": "^0.12.0",
"react-native-reanimated": "^1.1.0",
"react-native-tab-view": "^2.7.3",
"react-native-vector-icons": "^6.5.0",
"react-navigation": "^3.11.0",
"react-redux": "^7.1.0",
"redux": "^4.0.1",
"redux-thunk": "^2.3.0",
"reselect": "^4.0.0",
"styled-components": "^4.3.1",
"tls": "0.0.1"
},
"devDependencies": {
"#babel/core": "7.4.5",
"#babel/runtime": "7.4.5",
"babel-jest": "24.8.0",
"jest": "24.8.0",
"metro-react-native-babel-preset": "0.54.1",
"react-test-renderer": "16.8.3"
},
"jest": {
"preset": "react-native"
}
}
bable.config.js
module.exports = {
presets: ['module:metro-react-native-babel-preset'],
};
metro.config.js
module.exports = {
transformer: {
getTransformOptions: async () => ({
transform: {
experimentalImportSupport: false,
inlineRequires: false,
},
}),
},
};
Resolve building modules:
Delete the node_modules
yarn install
yarn add jetifier
yarn run jetify
rebuild project in android studio
Happy coding :)
I get this error when I run npm test. I've looked at a number of posts, solutions, etc. that suggest making edits to package.json, babel.config.js, jest.config.js and I still receive this error. I thought it could be a version issue with React Native, but I'm on the latest version 0.60.4 and it's mentioned in a few issues that this is solved in master. Perhaps I'm overlooking something, but I'm coming up short on what else it could be.
The following is the test that fails as a result:
import { geolocationRequest } from '../location';
let mockGeoCoding = jest.fn();
jest.mock('react-native-geocoding', () => ({
openURL: mockGeoCoding,
}));
describe('geolocationRequest', () => {
it('creates a properly formatted action', () => {
expect(geolocationRequest()).toMatchSnapshot();
})
})
Thoughts?
package.json
{
"name": "<app-name>",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start --config ../../../../rn-cli.config.js",
"start:ios": "react-native run-ios",
"start:android": "react-native run-android",
"clean:ios": "cd ios/ && pod deintegrate && pod install",
"clean:android": "cd android && ./gradlew clean",
"test": "jest --watch",
"test:coverage": "jest --coverage && open coverage/lcov-report/index.html",
"fix": "eslint --fix .",
"lint:ts": "tslint --fix --project ./tsconfig.json",
"lint:fix": "npm run lint:ts --fix",
"lint:check": "tslint --type-check --project"
},
"dependencies": {
"#react-native-community/async-storage": "1.4.2",
"appcenter": "1.12.2",
"appcenter-analytics": "1.12.2",
"appcenter-crashes": "1.12.2",
"axios": "^0.19.0",
"expo-font": "4.0.0",
"polyline": "0.2.0",
"react": "16.8.6",
"react-devtools": "3.6.1",
"react-native": "0.60.*",
"react-native-animatable": "1.3.2",
"react-native-auth0": "1.4.2",
"react-native-easy-grid": "0.2.1",
"react-native-elements": "1.1.0",
"react-native-geocoding": "0.3.0",
"react-native-gesture-handler": "1.3.0",
"react-native-maps": "0.24.2",
"react-native-vector-icons": "6.4.2",
"react-navigation": "3.9.1",
"react-redux": "7.1.0",
"redux": "4.0.0",
"redux-thunk": "2.3.0",
"scheduler": "0.14.0"
},
"devDependencies": {
"#babel/plugin-proposal-class-properties": "^7.5.5",
"#babel/preset-typescript": "^7.3.3",
"#types/enzyme": "^3.10.3",
"#types/enzyme-adapter-react-16": "^1.0.5",
"#types/jest": "^24.0.17",
"#types/polyline": "0.1.28",
"#types/react": "16.8.13",
"#types/react-native": "0.57.43",
"#types/react-native-auth0": "1.3.0",
"#types/react-native-vector-icons": "6.4.0",
"#types/react-redux": "^7.1.1",
"babel-core": "7.0.0-bridge.0",
"babel-eslint": "10.0.1",
"babel-jest": "24.3.1",
"babel-preset-expo": "5.1.1",
"enzyme": "^3.10.0",
"enzyme-adapter-react-16": "^1.14.0",
"enzyme-to-json": "^3.4.0",
"eslint": "5.15.1",
"eslint-config-airbnb": "17.1.0",
"eslint-plugin-import": "2.16.0",
"eslint-plugin-jsx-a11y": "6.2.1",
"eslint-plugin-react": "7.12.4",
"jest": "^24.3.1",
"jest-fetch-mock": "^2.1.2",
"jest-localstorage-mock": "^2.4.0",
"metro-react-native-babel-preset": "0.53.0",
"react-dom": "^16.8.6",
"react-native-typescript-transformer": "1.2.12",
"react-test-renderer": "^16.6.3",
"redux-mock-store": "^1.5.3",
"ts-jest": "^24.0.2",
"tslint": "5.16.0",
"typescript": "3.4.3"
},
"jest": {
"preset": "react-native"
}
}
jest.config.js
module.exports = {
"preset": 'react-native',
"verbose": true,
"setupFilesAfterEnv": ["<rootDir>/__tests__/setup.js", "jest-localstorage-mock"],
"roots": [
"<rootDir>/src"
],
"transform": {
"^.+\\.tsx?$": "ts-jest",
},
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$",
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"jsx",
"json",
"node"
],
"testPathIgnorePatterns": ['/node_modules/'],
"snapshotSerializers": ["enzyme-to-json/serializer"],
// "collectCoverageFrom": ["src/**/*.tsx"],
"collectCoverage": true,
};
babel.config.js
module.exports = {
"presets": ["module:metro-react-native-babel-preset"]
}
I've been struggling with the same issue.
Based on this comment on github From harudev
[...] So I tested some files to test project, and find out "react-native.config.js" file was the reason.
If there is someone suffered this issue, try to remove file or options from one of your "*.config.js" 😅
So I did remove all of my *.config.js file and the error is now gone.
Hopefully this could help you.
Note that you can reproduce the behavior of the *.confing.js file with package.json
For me this happened at an update of RN from 0.59.10 to 0.61.4.
I tried several fixes but nothing worked.
The only workaround that I've found was to set metro.config.js as below:
const blacklist = require('metro-config/src/defaults/blacklist');
module.exports = {
resolver: {
blacklistRE: blacklist([
/node_modules\/.*\/node_modules\/react-native\/.*/,
]),
},
transformer: {
getTransformOptions: async () => ({
transform: {
experimentalImportSupport: false,
inlineRequires: false,
},
}),
},
};
Source: jamalx31's answer from here:
https://github.com/facebook/react-native/issues/24065#issuecomment-537489786
The issue is reported and documented here:
https://github.com/facebook/react-native/issues/24065
and here:
https://github.com/facebook/react-native/issues/23943
Had the same error, after a good amount of soul searching (google searching)
i just ran npx react-native start oposed to runing my local react-native.
Hey I Have been trying to add #observer to my react component but this error occurs : Support for the experimental syntax 'decorators-legacy' isn't currently enabled here are the steps I have taken:
1.npm install mobx --save and npm i mobx mobx-react --save
tried using observable did not work
added
[
require(‘#babel/plugin-proposal-decorators’).default,
{
legacy: true
}
],
didn't work so i removed it
Created .babelrc in at the root directory and added
{
"presets": ["react-native"],
"plugins": [
[
"#babel/plugin-proposal-decorators",
{
"legacy": true
}
]
]
}
and still not working
Editing:
I did what you just said and same error:
when I npm start -- --reset-cache, this appears on my terminal, maybe it might help:
Emitted 'error' event at:
at Server.WebSocketServer._onServerError (/Users/red/mApp/node_modules/ws/lib/WebSocketServer.js:82:50)
at Server.emit (events.js:202:15)
at emitErrorNT (net.js:1283:8)
at processTicksAndRejections (internal/process/next_tick.js:76:17)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! mapp#0.0.1 start: `node node_modules/react-native/local-cli/cli.js start "--reset-cache"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the mapp#0.0.1 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Package.json file
{
"name": "mapp",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"#expo/vector-icons": "^10.0.2",
"babel-plugin-mobx-deep-action": "^1.6.1",
"jetifier": "^1.6.3",
"jsc-android": "241213.x.x",
"mobx": "^5.11.0",
"mobx-react": "^6.1.1",
"react": "16.8.3",
"react-native": "^0.59.10",
"react-native-background-fetch": "^2.6.0",
"react-native-background-geolocation": "^3.0.7",
"react-native-css-gradient": "^0.3.1",
"react-native-gesture-handler": "^1.3.0",
"react-native-ionicons": "^4.5.6",
"react-native-linear-gradient": "react-native-community/react-native-linear-gradient",
"react-native-maps": "^0.24.2",
"react-native-responsive-screen": "^1.2.2",
"react-native-svg": "^9.5.2",
"react-native-svg-transformer": "^0.13.0",
"react-native-vector-icons": "^6.5.0",
"react-native-vertical-tab-view": "^0.1.3",
"react-navigation": "^3.11.0",
"react-redux": "^7.1.0",
"redux": "^4.0.1"
},
"devDependencies": {
"#babel/core": "7.4.5",
"#babel/plugin-proposal-decorators": "^7.4.4",
"#babel/runtime": "7.4.5",
"babel-jest": "24.8.0",
"babel-plugin-transform-decorators-legacy": "^1.3.5",
"jest": "24.8.0",
"metro-react-native-babel-preset": "0.54.1",
"react-test-renderer": "16.8.3",
"redux-devtools": "^3.5.0"
},
"jest": {
"preset": "react-native"
}
}
You have to add plugin-proposal-decorators in babel.config.js
module.exports = {
presets: ['module:metro-react-native-babel-preset'],
plugins: [['#babel/plugin-proposal-decorators', { legacy: true }]],
};
Add "babel-preset-react-native": "4.0.0", and reset cache
{
"name": "mapp",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"#expo/vector-icons": "^10.0.2",
"babel-plugin-mobx-deep-action": "^1.6.1",
"jetifier": "^1.6.3",
"jsc-android": "241213.x.x",
"mobx": "^5.11.0",
"mobx-react": "^6.1.1",
"react": "16.8.3",
"react-native": "^0.59.10",
"react-native-background-fetch": "^2.6.0",
"react-native-background-geolocation": "^3.0.7",
"react-native-css-gradient": "^0.3.1",
"react-native-gesture-handler": "^1.3.0",
"react-native-ionicons": "^4.5.6",
"react-native-linear-gradient": "react-native-community/react-native-linear-gradient",
"react-native-maps": "^0.24.2",
"react-native-responsive-screen": "^1.2.2",
"react-native-svg": "^9.5.2",
"react-native-svg-transformer": "^0.13.0",
"react-native-vector-icons": "^6.5.0",
"react-native-vertical-tab-view": "^0.1.3",
"react-navigation": "^3.11.0",
"react-redux": "^7.1.0",
"redux": "^4.0.1"
},
"devDependencies": {
"#babel/core": "7.4.5",
"#babel/plugin-proposal-decorators": "^7.4.4",
"#babel/runtime": "7.4.5",
"babel-jest": "24.8.0",
"babel-plugin-transform-decorators-legacy": "^1.3.5",
"jest": "24.8.0",
"metro-react-native-babel-preset": "0.54.1",
"react-test-renderer": "16.8.3",
"redux-devtools": "^3.5.0"
},
"jest": {
"preset": "react-native"
}
}