Closed jonbiz closed 5 years ago
If you go out to ./node_modules/react-native/Libraries/react-native/react-native-implementation.js
you should see a line like const warnOnce = require('warnOnce');
on line 14
This line is importing the warnOnce module using haste. The warnOnce file should be in ./node_modules/react-native/Libraries/Utilities/warnOnce.js
(confirm it's there)
If the file is there then that means that it's missing in the haste map or otherwise not discoverable by metro so to fix you can force metro to rebuild the haste map from scratch by clearing the cache
To clear basically all RN caches you can run this:
watchman watch-del-all && rm -rf $TMPDIR/react-native-packager-cache-* && rm -rf $TMPDIR/metro-bundler-cache-* && rm -rf node_modules/ && npm cache clean --force && npm install && npm start -- --reset-cache
If you still have the issue let us know but note that this is more of an environment issue than a bug so we're limited in what we can do to help without a repo š
I am bumping into the same problem here. The warnOnce module is there, and force clearing the caches, restarting the packager doesn't solve the issue.
https://github.com/facebook/react-native/issues/23943 there is already open issue, maybe something useful post :( there @brightermatter you can follow that issue too
This is what I have tried:
remove all references of warnOnce in react-native-implementation.js
bundling failed: Error: Cannot find module 'warnOnce' at Function.Module._resolveFilename (module.js:547:15) at Function.Module._load (module.js:474:25) at Module.require (module.js:596:17) at require (internal/module.js:11:18) at Object.<anonymous> (/Users/gzcheng/Documents/ellentube-mobile/node_modules/react-native/Libraries/react-native/react-native-implementation.js:14:18) at Module._compile (module.js:652:30) at Object.Module._extensions..js (module.js:663:10) at Module.load (module.js:565:32) at tryModuleLoad (module.js:505:12)
copy the warnOnce.js from /node_modulesā©/react-native/āØLibrariesā©/Utilities to /node_modulesā©/react-nativeā©/āØLibrariesā©/āØreact-nativeā©.
That tells me that packager is able to find the warnOnce module. I am not an expert on this, but it sounds like some we maybe using some incompatible library versions? This issue has been bothering for about a week... would like to have it resolved soon...
My Package.json: "devDependencies": { "@babel/core": "^7.4.0", "@babel/plugin-proposal-nullish-coalescing-operator": "^7.2.0", "@babel/plugin-proposal-optional-chaining": "^7.0.0", "@babel/polyfill": "^7.0.0", "@babel/preset-flow": "^7.0.0", "@babel/preset-react": "^7.0.0", "@babel/register": "^7.0.0", "babel-eslint": "^8.2.6", "babel-jest": "^24.5.0", "babel-loader": "^8.0.5", "babel-polyfill": "^6.26.0", "babel-preset-es2015": "^6.22.0", "babel-preset-flow": "^6.23.0", "babel-preset-react-native": "^5.0.0", "concurrently": "^4.1.0", "empty": "^0.10.1", "enzyme": "^3.9.0", "enzyme-adapter-react-16": "^1.11.2", "enzyme-to-json": "^3.3.5", "eslint": "^5.15.3", "eslint-config-airbnb": "^17.1.0", "eslint-plugin-flowtype": "^2.46.1", "eslint-plugin-import": "^2.16.0", "eslint-plugin-jsx-a11y": "^6.2.1", "eslint-plugin-react": "^7.12.4", "flow-bin": "^0.95.1", "identity-obj-proxy": "^3.0.0", "istanbul-lib-coverage": "^2.0.3", "istanbul-lib-instrument": "^3.1.0", "istanbul-lib-source-maps": "^3.0.2", "jest": "^24.5.0", "metro-react-native-babel-preset": "^0.45.0", "mockdate": "^2.0.2", "node-sass": "^4.11.0", "precommit-hook": "^3.0.0", "react-native-mock": "^0.3.1", "react-test-renderer": "^16.8.5", "redux-mock-store": "^1.5.3" }, "dependencies": { "appcenter": "^1.9.0", "appcenter-analytics": "^1.9.0", "appcenter-crashes": "^1.9.0", "aws-sdk": "^2.429.0", "ellentube-helpers": "^1.2.7", "empty": "^0.10.1", "es6-promise": "^4.2.6", "flat": "^4.1.0", "jest-cli": "^24.5.0", "lodash": "^4.17.11", "moment": "^2.24.0", "prop-types": "^15.7.2", "react": "^16.8.5", "react-native": "^0.59.2", "react-native-admob": "github:warnerbros/react-native-admob#feature/custom-targeting", "react-native-animatable": "^1.3.2", "react-native-animated-sprite": "^0.11.1", "react-native-aws-cognito-js": "0.0.7", "react-native-code-push": "^5.6.0", "react-native-config": "^0.11.7", "react-native-device-info": "^1.1.0", "react-native-fbsdk": "^0.8.0", "react-native-fetch-blob": "^0.10.8", "react-native-gesture-handler": "^1.1.0", "react-native-google-signin": "^1.2.2", "react-native-htmlview": "^0.13.0", "react-native-image-crop-picker": "github:warnerbros/react-native-image-crop-picker#bugfix/camera_mediatype", "react-native-iphone-x-helper": "^1.2.0", "react-native-keyboard-aware-scroll-view": "^0.8.0", "react-native-keyboard-spacer": "^0.4.1", "react-native-linear-gradient": "^2.5.4", "react-native-open-settings": "^1.0.1", "react-native-orientation": "^3.1.3", "react-native-progress": "^3.6.0", "react-native-responsive": "^1.0.2", "react-native-snap-carousel": "^3.7.5", "react-native-svg": "^9.3.6", "react-native-swipeout": "^2.3.6", "react-native-swiper": "^1.5.14", "react-native-vector-icons": "^6.4.2", "react-native-video": "^4.4.0", "react-navigation": "^3.5.1", "react-navigation-redux-helpers": "^3.0.0", "react-redux": "^6.0.1", "redux": "^4.0.1", "redux-logger": "^3.0.6", "redux-thunk": "^2.3.0", "string-hash": "^1.1.3" },
.babelrc:
{ "presets": ["react-native","module:react-native", "@babel/preset-flow", "module:metro-react-native-babel-preset"], "plugins": ["@babel/plugin-proposal-nullish-coalescing-operator"], "retainLines": true, }
Any updates on this? Nothing seems to get rid of the warnOnce
doesn't exist error
... with error:(Unable to resolve module `warnOnce` from `/Users/.../mobile/node_modules/react-
native/Libraries/react-native/react-native-implementation.js`: Module `warnOnce` does not exist in
the Haste module map
What may cause the error below? SyntaxError in node_modules\react-native\Libraries\Utilities\warnOnce.js: Unexpected token (15:16) Failed building JavaScript bundle.
@rickhanlonii Should warnOnce.js be using types? Because it is, even though its not a typescript file. Could that be what's causing it to be left out of the haste map? As @gzcheng pointed out, it doesn't seem like the packager is having trouble finding the file.
I verified the file is there is in .\node_modules\react-native\Libraries\Utilities\WarnOnce.js
Changing my .babelrc
to only "presets": ["module:metro-react-native-babel-preset"]
as discussed here fixed the issue for me.
@ptsteadman I'm using bable.config.js and I'm already using that preset.
I did upgrade my rn project from 0.59.9 to 0.60.5.
And with some reason which I can't remember, I made a "react-native.config.js"
file.
After upgrade rn version, there is warnOnce issue.
But new test project doesn't have.
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"
š
Changing my
.babelrc
to only"presets": ["module:metro-react-native-babel-preset"]
as discussed here fixed the issue for me.
tried a few things, that solution worked for me
I start facing this issue after upgrading form RN 60.4 to 61.1.
My workaround is to change metro.config.js
to look like this
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,
},
}),
},
};
None of above suggested solutions fixed it for me. Still happening, I'm on react-native 0.60.5 and can't upgrade for the time being.
```shell watchman watch-del-all && rm -rf $TMPDIR/react-native-packager-cache-* && rm -rf $TMPDIR/metro-bundler-cache-* && rm -rf node_modules/ && npm cache clean --force && npm install && npm start -- --reset-cache
no its not there , what should i do ?
try use
npx react-native
not
react-native
Just stop the terminal window that is executing the metro (Ctrl+C) and in same terminal windows run this:
yarn start --reset-cache
It will work with no other changes!
try use
npx react-native
notreact-native
this solved my issue
I followed @rickhanlonii and @engineerbaraazakariya instructions, unfortunately did not work, posted a question in stackoverflow any new insight into this problem.
We have a legacy project with the same issue. I kid you not I tried everything that was suggested above. Anyway, hours later I finally managed to get around this by installing a specific old version of react native cli globally. TLDR: npm i -g react-native-cli@2.0.1
š Bug Report
I've been given a project and after having upgraded react-native to 0.59 the build succeeds but packager throws:
Also running
react-native run-ios
makes the application launch and then quit without interacting with the metro-bundler. Only XCode run works.Expected Behavior
The application to launch.
Environment
The project uses yarn workspaces and some dependencies get hoisted down to the RN App directory.
Root package.json
RN App package.json:
Podfile:
Is this related to dependencies?