Error on running a clean react-native project - react-native

Metro Bundler ready.
Loading dependency graph, done.
error: bundling failed: Error: invalid value for dynamic deps
behavior: null
at getDynamicDepsBehavior (C:\Projects\react-native\test\node_modules\metro\src\JSTransformer\worker\index.js:185:13)
at postTransform (C:\Projects\react-native\test\node_modules\metro\src\JSTransformer\worker\index.js:131:26)
at Object.transformCode [as transform] (C:\Projects\react-native\test\node_modules\metro\src\JSTransformer\worker\index.js:251:17)
at execMethod (C:\Projects\react-native\test\node_modules\jest-worker\build\child.js:92:29)
at process.on (C:\Projects\react-native\test\node_modules\jest-worker\build\child.js:42:7)
at process.emit (events.js:160:13)
at emit (internal/child_process.js:790:12)
BUNDLE [android, dev] ./index.js ░░░░░░░░░░░░░░░░ 0.0% (0/1), failed.

Sounds like a bad version of metro was published: https://github.com/facebook/metro/issues/126
Tried a fresh install and things are working now. Just running "npm install metro" to update to the hotfixed version (0.24.6) should also do the trick.

Related

How to fix Error: The project seems to require yarn but it's not installed

I just create this project with,
npm install --global yarn
vue create elecprog
yarn serve (-> error)
Also, I'm using VS Code terminal
PS D:\elcp\elecprog> yarn serve
yarn run v1.22.17
$ vue-cli-service serve
INFO Starting development server...
DONE Compiled successfully in 2889ms 오전 9:10:38
App running at:
- Local: http://localhost:[port]/
- Network: http://[myIp]:[port]/
ERROR Error: The project seems to require yarn but it's not installed.
Error: The project seems to require yarn but it's not installed.
at checkYarn (D:\elcp\elecprog\node_modules\#vue\cli-shared-utils\lib\env.js:46:43)
at exports.hasProjectYarn (D:\elcp\elecprog\node_modules\#vue\cli-shared-utils\lib\env.js:42:10)
at D:\elcp\elecprog\node_modules\#vue\cli-service\lib\commands\serve.js:312:34
at Hook.eval [as callAsync] (eval at create (D:\elcp\elecprog\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:44:1)
at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (D:\elcp\elecprog\node_modules\tapable\lib\Hook.js:18:14)
at Watching._done (D:\elcp\elecprog\node_modules\webpack\lib\Watching.js:287:28)
at D:\elcp\elecprog\node_modules\webpack\lib\Watching.js:209:21
at Compiler.emitRecords (D:\elcp\elecprog\node_modules\webpack\lib\Compiler.js:906:5)
at D:\elcp\elecprog\node_modules\webpack\lib\Watching.js:187:22
at D:\elcp\elecprog\node_modules\webpack\lib\Compiler.js:872:14
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
PS D:\elcp\elecprog>
In my case (OS: WINDOWS 11) installing yarn form official installer: https://classic.yarnpkg.com/lang/en/docs/install/#windows-stable
form tab Alternatives
However this is only for Yarn 1.22.19 and current Yarn version you can check here:
https://github.com/yarnpkg/berry/releases

"react-native init project" command not working

I am trying to create react native project with following command but getting error, Help me gyus:
react-native init Sample
Following error occurs:
This will walk you through creating a new React Native project in D:\React_Demos\Sample
Using yarn v1.17.3
Installing react-native...
yarn add v1.17.3
info No lockfile found.
[1/4] Resolving packages...
info There appears to be trouble with your network connection. Retrying...
info There appears to be trouble with your network connection. Retrying...
info There appears to be trouble with your network connection. Retrying...
info There appears to be trouble with your network connection. Retrying...
error An unexpected error occurred: "https://registry.npmjs.org/react-native: tunneling socket could not be established, cause=getaddrinfo ENOTFOUND 8888".
info If you think this is a bug, please open a bug report with the information provided in "D:\React_Demos\Sample\yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
Error: Command failed: yarn add react-native --exact
at checkExecSyncError (child_process.js:621:11)
at execSync (child_process.js:657:15)
at run (C:\Users\sachin.salunkhe\AppData\Roaming\npm\node_modules\react-native-cli\index.js:294:5)
at createProject (C:\Users\sachin.salunkhe\AppData\Roaming\npm\node_modules\react-native-cli\index.js:249:3)
at init (C:\Users\sachin.salunkhe\AppData\Roaming\npm\node_modules\react-native-cli\index.js:200:5)
at Object. (C:\Users\sachin.salunkhe\AppData\Roaming\npm\node_modules\react-native-cli\index.js:153:7)
at Module._compile (internal/modules/cjs/loader.js:777:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:788:10)
at Module.load (internal/modules/cjs/loader.js:643:32)
at Function.Module._load (internal/modules/cjs/loader.js:556:12) {
status: 1,
signal: null,
output: [ null, null, null ],
pid: 10924,
stdout: null,
stderr: null
}
Command yarn add react-native --exact failed.
Here is the yarn.log file:
Arguments:
C:\Program Files\nodejs\node.exe C:\Users\sachin.salunkhe\AppData\Roaming\npm\node_modules\yarn\bin\yarn.js add react-native --exact
PATH:
C:\Python27\;C:\Python27\Scripts;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\TortoiseSVN\bin;C:\Program Files\Git\cmd;C:\Program Files (x86)\PuTTY\;C:\Users\sachin.salunkhe\AppData\Roaming\npm;C:\adb;C:\Program Files\Apache Software Foundation\apache-maven-3.5.4;\bin;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\110\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\ManagementStudio\;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\120\DTS\Binn\;C:\Program Files\Microsoft SQL Server\120\DTS\Binn\;C:\ProgramData\chocolatey\bin;C:\Program Files\Java\jdk1.8.0_211\bin;C:\Users\sachin.salunkhe\AppData\Roaming\npm;C:\Program Files\nodejs\;C:\Users\sachin.salunkhe\AppData\Local\Android\Sdk\emulator\;C:\Program Files (x86)\Yarn\bin\;C:\Program Files\Apache Software Foundation\apache-maven-3.5.4\bin;C:\Program Files\Java\jdk1.8.0_181\;C:\Users\sachin.salunkhe\AppData\Local\Programs\Fiddler;C:\Users\sachin.salunkhe\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\sachin.salunkhe\AppData\Local\Yarn\bin
Yarn version:
1.17.3
Node version:
12.7.0
Platform:
win32 x64
Trace:
Error: https://registry.npmjs.org/react-native: tunneling socket could not be established, cause=getaddrinfo ENOTFOUND 8888
at ClientRequest.onError (C:\Users\sachin.salunkhe\AppData\Roaming\npm\node_modules\yarn\lib\cli.js:151950:17)
at Object.onceWrapper (events.js:291:20)
at ClientRequest.emit (events.js:203:13)
at Socket.socketErrorListener (_http_client.js:399:9)
at Socket.emit (events.js:203:13)
at emitErrorNT (internal/streams/destroy.js:91:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:59:3)
at processTicksAndRejections (internal/process/task_queues.js:77:11)
npm manifest:
{"name":"Sample","version":"0.0.1","private":true,"scripts":{"start":"node node_modules/react-native/local-cli/cli.js start"}}
yarn manifest:
No manifest
Lockfile:
No lockfile
First You Can Run This Command,
sudo npm install -g react-native-cli
then after run this command,
react-native init Sample
Make sure you have carried out this course.
choco install -y nodejs.install python2 jdk8 // If there is no choco, install it.
npm install -g react-native-cli
Download and install Android Studio // and setting Configure the ANDROID_HOME environment variable. and new SDK
react-native init AwesomeProject
First, remove node modules then install it again then install react-native cli. After that run init command.
I hope this is helpful for him.
1) Remove node_modules then update react native-cli with latest version.
2) npm install
3) react-native link
4) After that this command : react-native run-android
If you navigate to your npm folder before issuing the command, it should work, then you can always move the folder.
So
cd C:\Users\User\AppData\Roaming\npm
Then run
react-native init AppName

Error: While trying to resolve module 'prop-types' from file

Error when I run the command react-native run-android. The error was on metro bundler, when, the app is installing on my device, always shows this error.
The curious thing is that only happens me in this PC, I used other PC for a long time and when I pull git repo here (previously I was able to develop and test on that PC too), it's impossible to get it working for this error...
I think that maybe could be I removed yarn.lock many days ago and when I run npm install here produces this error?
I ommited my path for logic reasons:
Loading dependency graph, done.
error: bundling failed: Error: While trying to resolve module `prop-types` from file `PATH_TO_PROJECT_FOLDER\node_modules\react-redux\lib\components\Provider.js`, the package `PATH_TO_PROJECT_FOLDER\node_modules\react-redux\node_modules\prop-types\package.json` was successfully found. However, this package itself specifies a `main` module field that could not be resolved (`PATH_TO_PROJECT_FOLDER\node_modules\react-redux\node_modules\prop-types\index`. Indeed, none of these files exist:
* `PATH_TO_PROJECT_FOLDER\node_modules\react-redux\node_modules\prop-types\index(.native||.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)`
* `PATH_TO_PROJECT_FOLDER\node_modules\react-redux\node_modules\prop-types\index\index(.native||.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)`
at ResolutionRequest.resolveDependency (PATH_TO_PROJECT_FOLDER\node_modules\metro\src\node-haste\DependencyGraph\ResolutionRequest.js:65:15)
at DependencyGraph.resolveDependency (PATH_TO_PROJECT_FOLDER\node_modules\metro\src\node-haste\DependencyGraph.js:283:16)
at Object.resolve (PATH_TO_PROJECT_FOLDER\node_modules\metro\src\lib\transformHelpers.js:261:42)
at dependencies.map.result (PATH_TO_PROJECT_FOLDER\node_modules\metro\src\DeltaBundler\traverseDependencies.js:399:31)
at Array.map (<anonymous>)
at resolveDependencies (PATH_TO_PROJECT_FOLDER\node_modules\metro\src\DeltaBundler\traverseDependencies.js:396:18)
at PATH_TO_PROJECT_FOLDER\node_modules\metro\src\DeltaBundler\traverseDependencies.js:269:33
at Generator.next (<anonymous>)
at asyncGeneratorStep (PATH_TO_PROJECT_FOLDER\node_modules\metro\src\DeltaBundler\traverseDependencies.js:87:24)
at _next (PATH_TO_PROJECT_FOLDER\node_modules\metro\src\DeltaBundler\traverseDependencies.js:107:9)
DELTA [android, dev] ..\..\../index.android.js ▓▓▓▓▓▓▓▓░░░░░░░░ 51.9% (610/847), failed.
react-native: 0.59.1
react-native-cli: 2.0.1
Well.. I should not have deleted the yarn.lock file.
To fix:
Delete all .lock files on root folder project as #hend-el-sahli said.
yarn install
If you had the error unable to resolve module ./index, see that thread https://github.com/facebook/react-native/issues/24112
:)

react-native init gives ESOCKETTIMEDOUT error

I am using a Macbook and when I try to create a React Native app, it throws ESOCKETTIMEDOUT error.
I have tried to clean the npm and yarn cache however it doesn't help.
react-native init AwesomeProject
This will walk you through creating a new React Native project in /Users/gaurang.shah/Documents/personal/code/mobile/AwesomeProject
Using yarn v1.13.0
Installing react-native...
yarn add v1.13.0
info No lockfile found.
[1/4] 🔍 Resolving packages...
[2/4] 🚚 Fetching packages...
info There appears to be trouble with your network connection. Retrying...
info There appears to be trouble with your network connection. Retrying...
info There appears to be trouble with your network connection. Retrying...
info There appears to be trouble with your network connection. Retrying...
error An unexpected error occurred: "https://registry.yarnpkg.com/lodash/-/lodash-4.17.11.tgz: ESOCKETTIMEDOUT".
info If you think this is a bug, please open a bug report with the information provided in "/Users/gaurang.shah/Documents/personal/code/mobile/AwesomeProject/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
I am able to download the https://registry.yarnpkg.com/lodash/-/lodash-4.17.11.tgz file through my browser, so it can't be networking issue.
Stacktrace
Yarn version:
1.13.0
Node version:
11.10.0
Platform:
darwin x64
Trace:
Error: https://registry.yarnpkg.com/lodash/-/lodash-4.17.11.tgz: ESOCKETTIMEDOUT
at ClientRequest.<anonymous> (/usr/local/Cellar/yarn/1.13.0/libexec/lib/cli.js:130024:19)
at Object.onceWrapper (events.js:285:13)
at ClientRequest.emit (events.js:197:13)
at TLSSocket.emitRequestTimeout (_http_client.js:669:40)
at Object.onceWrapper (events.js:285:13)
at TLSSocket.emit (events.js:197:13)
at TLSSocket.Socket._onTimeout (net.js:447:8)
at listOnTimeout (timers.js:327:15)
at processTimers (timers.js:271:5)
npm manifest:
{"name":"AwesomeProject","version":"0.0.1","private":true,"scripts":{"start":"node node_modules/react-native/local-cli/cli.js start"}}
yarn manifest:
No manifest
Lockfile:
No lockfile
Had the same issue when retrieving big packages on a slow network. As suggested on this comment, increasing the network timeout for installing the packages worked for me.
Firstly, have your project directory created beforehand and then create a .yarnrc file inside of it having the following content:
network-timeout 600000
Now, just run the react-native init <project_name> command from the parent directory of your project as you did.
It is equivalent to running yarn like so:
yarn install --network-timeout 600000
If npm can be used, please use 'npm install' & it generates package-lock.json or 'yarn install --network-timeout <time in ms>' - generates yarn.lock. Both works for me.

Cannot running successful built react-native project on iOS simulator error

I'm programming an APP using react-native, but after I pulled from github this morning, it turned out that I couldn't run it anymore. The logs in the command line are as follows:
** BUILD SUCCEEDED **
The following commands produced analyzer issues:
Analyze Base/RCTModuleMethod.mm normal x86_64
(1 command with analyzer issues)
Logs in "react-native start" command line are as follows:
error: bundling failed: TypeError: Cannot read property 'bindings' of null
at Scope.moveBindingTo (/Users/martin/Desktop/ble-server/node_modules/#babel/traverse/lib/scope/index.js:978:13)
at BlockScoping.updateScopeInfo (/Users/martin/Desktop/ble-server/node_modules/babel-plugin-transform-es2015-block-scoping/lib/index.js:364:17)
at BlockScoping.run (/Users/martin/Desktop/ble-server/node_modules/babel-plugin-transform-es2015-block-scoping/lib/index.js:330:12)
at PluginPass.BlockStatementSwitchStatementProgram (/Users/martin/Desktop/ble-server/node_modules/babel-plugin-transform-es2015-block-scoping/lib/index.js:70:24)
at newFn (/Users/martin/Desktop/ble-server/node_modules/#babel/traverse/lib/visitors.js:237:21)
at NodePath._call (/Users/martin/Desktop/ble-server/node_modules/#babel/traverse/lib/path/context.js:65:20)
at NodePath.call (/Users/martin/Desktop/ble-server/node_modules/#babel/traverse/lib/path/context.js:40:17)
at NodePath.visit (/Users/martin/Desktop/ble-server/node_modules/#babel/traverse/lib/path/context.js:100:12)
at TraversalContext.visitQueue (/Users/martin/Desktop/ble-server/node_modules/#babel/traverse/lib/context.js:142:16)
BUNDLE [ios, dev] ../../index.js ░░░░░░░░░░░░░░░░ 0.0% (0/1), failed.
How could I run it again, it seems that there are no issues with codes.
Please run command first:
npm start
and then
react-native run-ios
You have probably updated react-native improperly please check the documentation.
You may have used npm audit fix which updates react-native.
To fix the problem you can downgrade the react-native version of the app with
npm install react-native#x.x.x"
Then re-compile project with
react-native run-ios"
And don't forget to restart the bundler as well with
react-native start
Then, if you still want to upgrade the react-native version you can use
react-native-git-upgrade