Error when starting metro server in Vscode - react-native

When I try to start metro server using yarn start, this error comes:
PS C:\Users\SAMSUNG\Desktop\myApp> yarn start
yarn run v1.22.17
warning ..\..\..\package.json: No license field
$ react-native start
error Cannot read properties of undefined (reading 'split').
TypeError: Cannot read properties of undefined (reading 'split')
at toIdentifier (C:\Users\SAMSUNG\Desktop\myApp\node_modules\toidentifier\index.js:26:6)
at forEachCode (C:\Users\SAMSUNG\Desktop\myApp\node_modules\http-errors\index.js:267:16)
at Array.forEach (<anonymous>)
at populateConstructorExports (C:\Users\SAMSUNG\Desktop\myApp\node_modules\http-errors\index.js:265:9)
at Object.<anonymous> (C:\Users\SAMSUNG\Desktop\myApp\node_modules\http-errors\index.js:31:1)
at Module._compile (node:internal/modules/cjs/loader:1103:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
info Run CLI with --verbose flag for more details.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
What is wrong?
PS: It was working before without any problem. I upgraded all the node modules inside project and also react-native version, and this error started to happen. I didn't do anything to node.js, it is the same as before(v16.14.0).

Related

Cyclic.sh is not detecting the start scrypt in package.json

I came here after some hours of reading and getting into the cyclic cool deployment process. https://www.cyclic.sh/
I was trying to host my express js app for free and linked my github repo to my cyclic.sh dashboard. (I added typescript to my express app btw) The build process of my app was successful ✅ , but when I check the logs on runtime it throws me this error: ERROR: Failed to run 'node index.js'
Successful build:
enter image description here
The complete error log in runtime:
2023-01-09 01:21:26.063: grep: /var/task/package.json: No such file or directory
2023-01-09 01:21:26.527: node:internal/modules/cjs/loader:998
throw err;
^
Error: Cannot find module 'dotenv'
Require stack:
- /var/task/index.js
at Module._resolveFilename (node:internal/modules/cjs/loader:995:15)
at Module._load (node:internal/modules/cjs/loader:841:27)
at Module.require (node:internal/modules/cjs/loader:1061:19)
at require (node:internal/modules/cjs/helpers:103:18)
at Object.<anonymous> (/var/task/index.js:33:34)
at Module._compile (node:internal/modules/cjs/loader:1159:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
at Module.load (node:internal/modules/cjs/loader:1037:32)
at Module._load (node:internal/modules/cjs/loader:878:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/var/task/index.js' ]
}
Thrown at:
at Module._resolveFilename (node:internal/modules/cjs/loader:995:15)
at Module._load (node:internal/modules/cjs/loader:841:27)
at Module.require (node:internal/modules/cjs/loader:1061:19)
2023-01-09 01:21:26.527: at require (node:internal/modules/cjs/helpers:103:18)
at /var/task/index.js:33:34
at Module._compile (node:internal/modules/cjs/loader:1159:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
at Module.load (node:internal/modules/cjs/loader:1037:32)
at Module._load (node:internal/modules/cjs/loader:878:12)
at executeUserEntryPoint (node:internal/modules/run_main:81:12)
Node.js v18.12.1
2023-01-09 01:21:26.562:
ERROR: Failed to run 'node index.js'.
Exited with code: 1
I noticed that the problem is that cyclic is not running node in the correct directory. The correct command executed should be: node dist/index.js. Because of that, I added the scripts configuration in my package.json as it is specified in https://docs.cyclic.sh/overview/launch, but for some reason cyclic is not reading that change in my scripts. (It works well locally)
I am not sure if I am missing something. I am very close, but I am stock at this point. I attatched some screenshots about the successful build, the failure and my package.json configuration.
My package.json file configuration:
enter image description here
Any help would be very appreaciated! Thanks in advance!

New ReactNative App Triggers Bundler Error: error Unexpected token =

Every time I try to create a new React Native app, I receive this error in the Metro Bundler:
error Unexpected token =.
/Users/lukeschoenberger/repos/PodApp/node_modules/metro-cache/src/stores/HttpStore.js:31
static HttpError = HttpError;
^
SyntaxError: Unexpected token =
at Module._compile (internal/modules/cjs/loader.js:723:23)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (/Users/lukeschoenberger/repos/PodApp/node_modules/metro-cache/src/stores/HttpGetStore.js:12:19)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
info Run CLI with --verbose flag for more details.
Process terminated. Press <enter> to close the window
I'm running: npx react-native run-ios.
When I create the script, I create the app, I run: npx react-native init AppName
I'm on node v14.17.1.
The startup script also says: success Successfully launched the app on the simulator
What am I doing wrong?
I had the same error because I was running on node v10.
After switching to node v14.17.5 (npm v6.14.14) via nvm, it solved the issue.
Can you verify you are really on v14.17.1?
For me, I tried using node v14.17.5 and it didn't work. I removed:
static HttpError = HttpError;
static NetworkError = NetworkError;
from node_modules/metro-config/node_modules/metro-cache/src/stores/HttpStore.js
and it worked.
Can use patch-package as well:
yarn patch-package metro-config/metro-cache

Titanium - new versions

I created an app with Titanium, 2 years ago. I want to develop a new one, but from the beginning, it doesn't work.
I just updated the SDK to 7.4.0GA, and, when I run the command "ti create" in my console, there is an error :
[ERROR] Failed to load command "create"
[ERROR] SyntaxError: Unexpected token ...
at Object.<anonymous> (...\AppData\Roaming\npm\node_modules\titanium\node_modules\node-appc\lib\exception.js:33:27)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.defineProperty.get (...\AppData\Roaming\npm\node_modules\titanium\node_modules\node-appc\lib\appc.js:63:11)
at ...\AppData\Roaming\npm\node_modules\titanium\node_modules\node-appc\node_modules\async\dist\async.js:2111:9
at apply (...\AppData\Roaming\npm\node_modules\titanium\node_modules\node-appc\node_modules\async\dist\async.js:21:25)
at ...\AppData\Roaming\npm\node_modules\titanium\node_modules\node-appc\node_modules\async\dist\async.js:56:12
at _insert (...\AppData\Roaming\npm\node_modules\titanium\node_modules\node-appc\node_modules\async\dist\async.js:2220:9)
at Object.q.push (...\AppData\Roaming\npm\node_modules\titanium\node_modules\node-appc\node_modules\async\dist\async.js:2267:13)
at Object.findExecutable (...\AppData\Roaming\npm\node_modules\titanium\node_modules\node-appc\lib\subprocess.js:113:8)
at resolveNode (...\AppData\Roaming\npm\node_modules\titanium\lib\titanium.js:97:34)
at ...\AppData\Roaming\npm\node_modules\titanium\lib\titanium.js:74:5
at Object.<anonymous> (...\AppData\Roaming\npm\node_modules\titanium\lib\titanium.js:80:2)
I also tried with SDK 7.3.1.GA
What can I do ?
Thanks a lot :)
Update your CLI tools. Run npm install -g titanum appcelerator alloy and appc setup to check the environment.
After that ti create or appc ti create should work

Error: Cannot find module 'wrappy'

When I try to restore my packages via yarn I'm receiving the following error:
npm run yarn --ignore-platform --ignore-optional
...
error C:\Users\mdepouw\source\repos\MyRepo\node_modules\node-sass: Command failed.
Exit code: 1
Command: node scripts/install.js
Arguments:
Directory: C:\Users\mdepouw\source\repos\MyRepo\node_modules\node-sass
Output:
module.js:471
throw err;
^
Error: Cannot find module 'wrappy'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (C:\Users\mdepouw\source\repos\MyRepo\node_modules\inflight\inflight.js:1:76)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
When I a npm install it works fine.
Why does one work but not the other?
This usually happens when you update npm. To resolve this go to path "C:\Users[username]\AppData\Roaming" and delete "npm" and "npm-cache" folders. Then uninstall nodejs and reinstall using updated installer. This should solve your problem.

Error starting up React Native packager "Cannot find module metro-bundler"

I have a simple React Native project that works fine on the original machine I created it on, but when I clone the git repo on another machine and try to run the iOS project, I get this error when starting the packager:
module.js:471
throw err;
^
Error: Cannot find module 'metro-bundler/build/lib/formatBanner'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (.../node_modules/react-native/local-cli/server/checkNodeVersion.js:12:20)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
Process terminated. Press <enter> to close the window
The project is on GitHub here. I purposely didn't git ignore the node_modules folder because this project has some slight modifications to React Native itself. It seems if I delete node_modules and yarn install it resolves the issue but I'd like to have the GitHub repo in a state where you can clone and you don't need to run anything to set up dependencies.