Description:
Getting the following error when starting my app using npx react-native start
or npx react-native run-android
I already tried clearing my caches using npx react-native start --reset-cache
and cache cleaner scripts from npm
warning: the transform cache was reset.
Loading dependency graph...Failed to construct transformer: Error: Cannot create a string longer than 0x3fffffe7 characters
at Object.slice (buffer.js:593:37)
at Buffer.toString (buffer.js:790:14)
at Object.readFileSync (fs.js:403:41)
at getContent (D:\MyApp\node_modules\metro\node_modules\jest-haste-map\build\worker.js:149:41)
at Object.<anonymous> (D:\MyApp\node_modules\metro\node_modules\jest-haste-map\build\worker.js:199:9)
at Generator.next (<anonymous>)
at asyncGeneratorStep (D:\MyApp\node_modules\metro\node_modules\jest-haste-map\build\worker.js:78:24)
at _next (D:\MyApp\node_modules\metro\node_modules\jest-haste-map\build\worker.js:98:9)
at D:\MyApp\node_modules\metro\node_modules\jest-haste-map\build\worker.js:103:7
at new Promise (<anonymous>) {
type: 'Error',
code: 'ERR_STRING_TOO_LONG'
}
(node:1972) UnhandledPromiseRejectionWarning: Error: Cannot create a string longer than 0x3fffffe7 characters
at Object.slice (buffer.js:593:37)
at Buffer.toString (buffer.js:790:14)
at Object.readFileSync (fs.js:403:41)
at getContent (D:\MyApp\node_modules\metro\node_modules\jest-haste-map\build\worker.js:149:41)
at Object.<anonymous> (D:\MyApp\node_modules\metro\node_modules\jest-haste-map\build\worker.js:199:9)
at Generator.next (<anonymous>)
at asyncGeneratorStep (D:\MyApp\node_modules\metro\node_modules\jest-haste-map\build\worker.js:78:24)
at _next (D:\MyApp\node_modules\metro\node_modules\jest-haste-map\build\worker.js:98:9)
at D:\MyApp\node_modules\metro\node_modules\jest-haste-map\build\worker.js:103:7
at new Promise (<anonymous>)
(node:1972) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:1972) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
React Native version:
Run `react-native info` in your terminal and copy the results here.
System:
OS: Windows 10 10.0.18363
CPU: (8) x64 Intel(R) Core(TM) i7-4770K CPU @ 3.50GHz
Memory: 2.34 GB / 15.91 GB
Binaries:
Node: 12.16.1 - C:\Program Files\nodejs\node.EXE
Yarn: 1.13.0 - ~\AppData\Roaming\npm\yarn.CMD
npm: 6.11.3 - ~\AppData\Roaming\npm\npm.CMD
SDKs:
Android SDK:
API Levels: 24, 25, 26, 28
Build Tools: 23.0.1, 23.0.3, 25.0.2, 26.0.1, 26.0.2, 28.0.3
IDEs:
Android Studio: Version 3.5.0.0 AI-191.8026.42.35.6010548
npmPackages:
react: 16.9.0 => 16.9.0
react-native: ^0.61.5 => 0.61.5
Steps To Reproduce
Provide a detailed list of steps that reproduce the issue.
Issues without reproduction steps or code are likely to stall.
- Create an App named
MyApp
with 1 file - Copy the App to a different folder and rename all occurrences of
MyApp
withMyApp2
Expected Results
It launches
So the problem was that i had a folder where i kept all my assets (logos, banners, psds, …) which was rather big and called _assets. moving that folder a level higher out of the root folder fixed the problem
EDIT:
Adding it to the blacklist in metro.config.js allowed me to have it in my project as well.
const blacklist = require(‘metro-config/src/defaults/blacklist’);
module.exports = {
resolver: {
blacklistRE: blacklist([/_assets\/.*/]),
},
};
thanks to https://stackoverflow.com/questions/41813211/how-to-make-react-native-packager-ignore-certain-directories