I just started working with React Native. Now I am trying to get my client running however I'm facing this issue
Requiring unknown module "./lib/templates/bootstrap".If you are sure the module is there, try restarting the packager or running "npm install".
package.json
{
"name": "client",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"eslint": "^2.10.1",
"eslint-config-airbnb": "^9.0.1",
"eslint-plugin-import": "^1.8.0",
"eslint-plugin-jsx-a11y": "^1.2.0",
"eslint-plugin-react": "^5.1.1",
"react": "15.3.2",
"react-native": "^0.37.0",
"tcomb-form-native": "^0.5.0",
"whatwg-fetch": "^1.0.0"
},
"jest": {
"preset": "jest-react-native"
},
"devDependencies": {
"babel-jest": "17.0.0",
"babel-preset-react-native": "1.9.0",
"jest": "17.0.0",
"jest-react-native": "17.0.0",
"react-test-renderer": "15.3.2"
}
}
Then I tried to search the text /lib/templates/bootstrap in my project and I found it in index.android.bundle.
module.exports=LoginView;
}, "client/views/LoginView.js");
__d(559 / tcomb-form-native/index.js /, function(global, require, module, exports) {var _lib=require(560 / ./lib /);var _lib2=babelHelpers.interopRequireDefault(_lib);
var _en=require(620 / ./lib/i18n/en /);var _en2=babelHelpers.interopRequireDefault(_en);
var _bootstrap=require('./lib/templates/bootstrap');var _bootstrap2=babelHelpers.interopRequireDefault(_bootstrap);
var _bootstrap3=require(621 / ./lib/stylesheets/bootstrap /);var _bootstrap4=babelHelpers.interopRequireDefault(_bootstrap3);
Anyone can shed some lights on this ?
Related
I keep getting export * from #react-navigation/core. Unexpected token export whenever I try to run my test for my project :
https://github.com/MatTaNg/React-Native
(run npm i && npm run test:watch [don't worry npm i doesn't take long its a small project])
Here's my package.json
{
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"test": "jest",
"test:watch": "npm run test -- --watchAll"
},
"dependencies": {
"#types/jest": "^26.0.8",
"#types/node": "^14.0.27",
"expo": "~38.0.8",
"expo-status-bar": "^1.0.2",
"react": "~16.11.0",
"react-dom": "~16.11.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-38.0.2.tar.gz",
"react-native-gesture-handler": "^1.7.0",
"react-native-reanimated": "^1.10.1",
"react-native-responsive-screen": "^1.4.1",
"react-native-router-flux": "^4.2.0",
"react-native-screens": "^2.9.0",
"react-native-web": "~0.11.7",
"react-test-renderer": "^16.13.1"
},
"devDependencies": {
"#babel/core": "^7.8.6",
"#testing-library/jest-native": "^3.3.0",
"#testing-library/react-native": "^7.0.1",
"#types/react": "~16.9.41",
"#types/react-native": "~0.62.13",
"jest": "^26.2.2",
"typescript": "~3.9.5"
},
"transformIgnorePatterns": [
"node_modules/(?!(jest-)?react-native)",
"node_modules/?!(react-navigation)"
],
"jest": {
"preset": "react-native"
},
"private": true
}
I'm just not able to figure this out. Something with react-navigation core is messing everything up I think.
Another, separate issue is that for some reason the HTML (jsx) isn't showing up on my mobile device (IOS) but its working fine in the browser. Seems like its just ignoring all the html inside my route.
EDIT:
I've followed the docs https://docs.expo.io/guides/testing-with-jest/
I've just added this to my package.json:
"jest": {
"preset": "react-native",
"transformIgnorePatterns": [
"node_modules/(?!(jest-)?react-native|react-clone-referenced-element|#react-native-community|expo(nent)?|#expo(nent)?/.*|react-navigation|#react-navigation/.*|#unimodules/.*|unimodules|sentry-expo|native-base|#sentry/.*)"
]
},
But now I'm getting this error when I run my test:
you are using expo therefore, you need to install expo-jest and use "preset": "jest-expo"
yarn add jest-expo --dev
package.json
"scripts": {
...
"test": "jest"
},
"jest": {
"preset": "jest-expo"
}
Here is DOCS for Expo jest. so, change expo jest configuration according to docs like below.
{
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"test": "jest",
"test:watch": "npm run test -- --watchAll"
},
"dependencies": {
"#types/jest": "^26.0.8",
"#types/node": "^14.0.27",
"expo": "~38.0.8",
"expo-status-bar": "^1.0.2",
"react": "~16.11.0",
"react-dom": "~16.11.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-38.0.2.tar.gz",
"react-native-gesture-handler": "^1.7.0",
"react-native-reanimated": "^1.10.1",
"react-native-responsive-screen": "^1.4.1",
"react-native-router-flux": "^4.2.0",
"react-native-screens": "^2.9.0",
"react-native-web": "~0.11.7",
"react-test-renderer": "^16.13.1"
},
"devDependencies": {
"#babel/core": "^7.8.6",
"#testing-library/jest-native": "^3.3.0",
"#testing-library/react-native": "^7.0.1",
"#types/react": "~16.9.41",
"#types/react-native": "~0.62.13",
"jest": "^26.2.2",
"typescript": "~3.9.5",
"jest-expo": "^38.0.0"
},
"jest": {
"preset": "jest-expo",
"transformIgnorePatterns": [
"node_modules/(?!(jest-)?react-native|react-clone-referenced-element|#react-native-community|expo(nent)?|#expo(nent)?/.*|react-navigation|#react-navigation/.*|#unimodules/.*|unimodules|sentry-expo|native-base|#sentry/.*)"
]
},
"private": true
}
hope this will help you
Just upgraded my react-native project from version 0.46.4 to 0.60.0 using yarn or npm and run with visual studio code result following error.
[Error] Error: Can't get fulfillment value from any promise, all promises were rejected.
This is my old package.json:
{
"name": "ShoppingApp",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"native-base": "2.2.1",
"react": "16.0.0-alpha.12",
"react-native": "0.46.4",
"react-native-grid-view": "https://github.com/lucholaf/react-native-grid-view.git",
"react-native-scalable-image": "https://github.com/ihor/react-native-scalable-image.git",
"react-native-tabbar-bottom": "^1.0.4",
"react-native-numeric-input": "^1.8.0",
"react-navigation": "https://github.com/Maxeh/react-navigation.git",
"rn-viewpager": "https://github.com/zbtang/React-Native-ViewPager.git"
},
"devDependencies": {
"babel-jest": "21.0.0",
"babel-preset-react-native": "3.0.2",
"jest": "21.0.1",
"react-test-renderer": "16.0.0-alpha.12"
},
"jest": {
"preset": "react-native"
}
}
And my new package.json here
{
"name": "ShoppingApp",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"native-base": "^2.12.1",
"react": "^16.8.6",
"react-native": "^0.60.0",
"react-native-grid-view": "^0.4.1",
"react-native-i18n": "^2.0.15",
"react-native-numeric-input": "^1.8.0",
"react-native-scalable-image": "^0.5.1",
"react-native-tabbar-bottom": "^1.0.4",
"react-navigation": "^3.11.0",
"rn-viewpager": "^1.2.9"
},
"devDependencies": {
"babel-jest": "21.0.0",
"babel-preset-react-native": "3.0.2",
"jest": "21.0.1",
"react-test-renderer": "16.0.0-alpha.12"
},
"jest": {
"preset": "react-native"
}
}
When I build my project with Visual Studio Code, show following error.
[Error] Error: Can't get fulfillment value from any promise, all promises were rejected.
Please let me upgrade my project and build it.
I found way to upgrade.
I changed dependencies carefully like following package.json.
{
"name": "ShoppingApp",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"react": "^16.8.6",
"react-native": "^0.60.0",
"react-native-grid-view": "https://github.com/lucholaf/react-native-grid-view.git",
"react-native-numeric-input": "^1.8.0",
"react-native-scalable-image": "https://github.com/ihor/react-native-scalable-image.git",
"react-native-tabbar-bottom": "^1.0.4",
"react-native-vector-icons": "^6.6.0",
"react-navigation": "https://github.com/Maxeh/react-navigation.git",
"rn-viewpager": "https://github.com/zbtang/React-Native-ViewPager.git"
},
"devDependencies": {
"#babel/core": "^7.5.0",
"#babel/runtime": "^7.5.2",
"#react-native-community/eslint-config": "^0.0.5",
"babel-jest": "^24.8.0",
"eslint": "^6.0.1",
"jest": "^24.8.0",
"metro-react-native-babel-preset": "^0.55.0",
"react-test-renderer": "^16.8.6"
},
"jest": {
"preset": "react-native"
}
}
As you can see I removed native-base and updated dev dependencies and add babel/core.
And delete node_modules, yarn or npm again.
I am trying to make ESLint and Prettier work for days but whatever I do, nothing changes.
I don't even know what I installed globally but here is my project's local package.json
{
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"babel-core": "^6.26.3",
"babel-loader": "^8.0.4",
"babel-preset-react-native": "4.0.0",
"global": "^4.3.2",
"react": "16.5.0",
"react-native": "0.57.2",
"react-native-linear-gradient": "^2.4.0",
"react-native-navigation": "^1.1.488",
"react-native-snap-carousel": "^3.7.5",
"react-native-vector-icons": "^6.0.2",
"react-navigation": "^2.17.0"
},
"devDependencies": {
"babel-eslint": "^10.0.1",
"babel-jest": "23.6.0",
"eslint-config-prettier": "^3.1.0",
"eslint-plugin-prettier": "^3.0.0",
"jest": "23.6.0",
"prettier": "^1.14.3",
"react-test-renderer": "16.5.0"
},
"jest": {
"preset": "react-native"
}
}
my .eslintrc contains
{
"extends": ["react-app", "plugin:prettier/recommended"]
}
And output in ESLint section says
[Error - 1:15:10 PM] Cannot find module 'eslint-plugin-prettier' Referenced from: /Users/me/project/.eslintrc
I have VSCode settings adjusted, so that is fine, but this simple doesn't work.
I believe you're missing the main eslint package.
Can you try adding this to your package.json
"eslint": "^5.8.0",
Installing all required packages wasn't enough for me, I also had to restart my IDE (Webstorm).
How the issue appeared ?
1 - I started a new blank react-native project using react-native init projectName
2 - I moved screens and components from exiting project to the new one
3 - I installed the required npm modules that's I use inside the project (including expo) npm install --save expo
that's the error which I got "check the below image" , however I installed expo
that's my package.json file
{
"name": "taplot",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"axios": "^0.18.0",
"expo": "^29.0.0",
"native-base": "^2.7.2",
"react": "16.4.1",
"react-native": "0.56.0",
"react-native-easy-grid": "^0.2.0",
"react-native-flags": "^1.0.0",
"react-native-icon-badge": "^1.1.3",
"react-native-public-ip": "^1.0.0",
"react-native-toaster": "^1.2.2",
"react-navigation": "^2.9.3"
},
"devDependencies": {
"babel-jest": "23.4.2",
"babel-preset-react-native": "5.0.2",
"jest": "23.4.2",
"react-test-renderer": "16.4.1"
},
"jest": {
"preset": "react-native"
}
}
I'm trying to run an android project on the android studio emulator and every time I'm getting this error message can anyone help please? I linked an image above
package.json :
{
"name": "AwesomeProjec",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"babel-core": "^6.26.3",
"babel-loader": "^7.1.5",
"react": "16.4.1",
"react-native": "^0.55.4"
},
"devDependencies": {
"babel-core": "^6.26.3",
"babel-jest": "23.4.2",
"babel-loader": "^7.1.5",
"babel-preset-react-native": "5",
"gulp-babel": "^7.0.1",
"jest": "23.4.2",
"react-test-renderer": "16.4.1"
},
"jest": {
"preset": "react-native"
}
}
Try to create the project with below command:-
react-native init ProjectName --version react-native#0.55.0