UnknownError: Connection refused (Connection refused) - selenium

I'm running a grunt test within a MEAN JS stack app and found an issue that I can't work out its cause.
Running webdriver-manager on its own, i.e. webdriver-manager start, works fine, but running via the grunt test task seems to fail.
I also noticed that the port is different (not 4444). Not sure how to change this either.
Running "protractor:e2e" (protractor) task
webdriver-manager path: /Users/valdy/Development/MeanJSApp/node_modules/protractor/bin/webdriver-manager
selenium standalone is up to date.
chromedriver is up to date.
Starting selenium standalone server...
[launcher] Running 1 instances of WebDriver
Selenium standalone server started at http://192.168.0.115:64594/wd/hub
/Users/valdy/Development/MeanJSApp/node_modules/selenium-webdriver/lib/atoms/error.js:108
var template = new Error(this.message);
^
UnknownError: Connection refused (Connection refused)
at new bot.Error (/Users/valdy/Development/MeanJSApp/node_modules/selenium-webdriver/lib/atoms/error.js:108:18)
at Object.bot.response.checkResponse (/Users/valdy/Development/MeanJSApp/node_modules/selenium-webdriver/lib/atoms/response.js:109:9)
at /Users/valdy/Development/MeanJSApp/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:160:24
at promise.ControlFlow.runInFrame_ (/Users/valdy/Development/MeanJSApp/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:1857:20)
at wrappedCtr.notify (/Users/valdy/Development/MeanJSApp/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:2448:25)
at promise.Promise.notify_ (/Users/valdy/Development/MeanJSApp/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:564:12)
at Array.forEach (native)
at promise.Promise.notifyAll_ (/Users/valdy/Development/MeanJSApp/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:553:15)
at goog.async.run.processWorkQueue (/Users/valdy/Development/MeanJSApp/node_modules/selenium-webdriver/lib/goog/async/run.js:130:15)
at process._tickCallback (internal/process/next_tick.js:103:7)
From: Task: WebDriver.createSession()
at Function.webdriver.WebDriver.acquireSession_ (/Users/valdy/Development/MeanJSApp/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:157:22)
at Function.webdriver.WebDriver.createSession (/Users/valdy/Development/MeanJSApp/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:131:30)
at Builder.build (/Users/valdy/Development/MeanJSApp/node_modules/selenium-webdriver/builder.js:445:22)
at LocalDriverProvider.DriverProvider.getNewDriver (/Users/valdy/Development/MeanJSApp/node_modules/protractor/lib/driverProviders/driverProvider.js:38:7)
at Runner.createBrowser (/Users/valdy/Development/MeanJSApp/node_modules/protractor/lib/runner.js:182:37)
at /Users/valdy/Development/MeanJSApp/node_modules/protractor/lib/runner.js:263:21
at _fulfilled (/Users/valdy/Development/MeanJSApp/node_modules/q/q.js:797:54)
at self.promiseDispatch.done (/Users/valdy/Development/MeanJSApp/node_modules/q/q.js:826:30)
at Promise.promise.promiseDispatch (/Users/valdy/Development/MeanJSApp/node_modules/q/q.js:759:13)
at /Users/valdy/Development/MeanJSApp/node_modules/q/q.js:573:44
[launcher] Process exited with error code 1
>>
Warning: Tests failed, protractor exited with code: 1 Use --force to continue.
Aborted due to warnings.
This is the config for tests.js (/config/assets/tests.js):
'use strict';
module.exports = {
tests: {
// client: ['modules/*/tests/client/**/*.js'],
client: ['modules/forum/tests/client/**/*.js'],
// server: ['modules/*/tests/server/**/*.js'],
server: ['modules/forum/tests/server/**/*.js'],
e2e: ['modules/*/tests/e2e/**/*.js']
// e2e: ['modules/forum/tests/e2e/**/*.js']
}
};
I also found that protractor's config.json, under /node_module/protractor/config.json has this configuration:
{
"webdriverVersions": {
"selenium": "2.47.1",
"chromedriver": "2.19",
"iedriver": "2.47.0"
}
}
And this is my own protractor.config.js, in the root of the web app:
'use strict';
// Protractor configuration
var config = {
specs: ['modules/*/tests/e2e/*.js']
};
if (process.env.TRAVIS) {
config.capabilities = {
browserName: 'firefox'
};
}
exports.config = config;
And here is protractor's npm descriptor (/node_module/protractor/package.json):
{
"_args": [
[
{
"raw": "Protractor#2.5.1",
"scope": null,
"escapedName": "Protractor",
"name": "Protractor",
"rawSpec": "2.5.1",
"spec": "2.5.1",
"type": "version"
},
"/Users/valdy/Development/MeanJSApp"
]
],
"_from": "Protractor#2.5.1",
"_id": "protractor#2.5.1",
"_inCache": true,
"_location": "/protractor",
"_nodeVersion": "0.12.7",
"_npmUser": {
"name": "angularcore",
"email": "angular-core+npm#google.com"
},
"_npmVersion": "2.11.3",
"_phantomChildren": {
"boom": "2.10.1",
"chalk": "1.1.3",
"combined-stream": "1.0.5",
"core-util-is": "1.0.2",
"cryptiles": "2.0.5",
"ctype": "0.5.3",
"forever-agent": "0.6.1",
"graceful-readlink": "1.0.1",
"hoek": "2.16.3",
"inherits": "2.0.3",
"is-my-json-valid": "2.16.0",
"isstream": "0.1.2",
"json-stringify-safe": "5.0.1",
"lru-cache": "2.7.3",
"oauth-sign": "0.8.2",
"sigmund": "1.0.1",
"sntp": "1.0.9",
"string_decoder": "0.10.31",
"stringstream": "0.0.5",
"tough-cookie": "2.3.2"
},
"_requested": {
"raw": "Protractor#2.5.1",
"scope": null,
"escapedName": "Protractor",
"name": "Protractor",
"rawSpec": "2.5.1",
"spec": "2.5.1",
"type": "version"
},
"_requiredBy": [
"#USER",
"/grunt-protractor-runner",
"/gulp-protractor"
],
"_resolved": "https://registry.npmjs.org/protractor/-/protractor-2.5.1.tgz",
"_shasum": "03d6c93cd7c268f4250177d55a2fec8a198372cd",
"_shrinkwrap": null,
"_spec": "Protractor#2.5.1",
"_where": "/Users/valdy/Development/MeanJSApp",
"author": {
"name": "Julie Ralph",
"email": "ju.ralph#gmail.com"
},
"bin": {
"protractor": "bin/protractor",
"webdriver-manager": "bin/webdriver-manager"
},
"bugs": {
"url": "https://github.com/angular/protractor/issues"
},
"dependencies": {
"accessibility-developer-tools": "~2.6.0",
"adm-zip": "0.4.4",
"glob": "~3.2",
"html-entities": "~1.1.1",
"jasmine": "2.3.2",
"jasminewd": "1.1.0",
"jasminewd2": "0.0.6",
"lodash": "~2.4.1",
"minijasminenode": "1.1.1",
"optimist": "~0.6.0",
"q": "1.0.0",
"request": "~2.57.0",
"saucelabs": "~1.0.1",
"selenium-webdriver": "2.47.0",
"source-map-support": "~0.2.6"
},
"description": "Webdriver E2E test wrapper for Angular.",
"devDependencies": {
"chai": "~3.3.0",
"chai-as-promised": "~5.1.0",
"cucumber": "~0.6.0",
"expect.js": "~0.2.0",
"express": "~3.3.4",
"jshint": "2.5.0",
"mocha": "2.3.3",
"rimraf": "~2.2.6"
},
"directories": {},
"dist": {
"shasum": "03d6c93cd7c268f4250177d55a2fec8a198372cd",
"tarball": "https://registry.npmjs.org/protractor/-/protractor-2.5.1.tgz"
},
"gitHead": "645133d557f1059d9e885f2566fc4c29ce7c19cc",
"homepage": "https://github.com/angular/protractor",
"keywords": [
"angular",
"test",
"testing",
"webdriver",
"webdriverjs",
"selenium"
],
"license": "MIT",
"main": "lib/protractor.js",
"maintainers": [
{
"name": "juliemr",
"email": "ju.ralph#gmail.com"
},
{
"name": "angularcore",
"email": "angular-core+npm#google.com"
}
],
"name": "protractor",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git://github.com/angular/protractor.git"
},
"scripts": {
"pretest": "jshint lib spec scripts",
"start": "node testapp/scripts/web-server.js",
"test": "node scripts/test.js"
},
"version": "2.5.1"
}

Here is my best guess at what's going on:
You are launching with the selenium standalone server locally using your ip address and a port that is not 4444. This means that you did not select seleniumAddress: "http://localhost:4444/wd/hub" or directConnect: true. I'll have a code snippet below of what this looks like.
If you are launching locally and not on Travis, then Protractor launches by the Chrome browser by default. This also means that you should have downloaded the ChromeDriver.
You should upgrade from Protractor 2.5 to the latest. Protractor is strongly coupled with the entire stack: selenium-webdriver, the standalone server, browser drivers and browsers. If you are using an up-to-date browser and Protractor 2.5, then probably webdriver-manager downloaded old binaries that may be incompatible with your browser.
Here is the code snippet:
exports.config = {
// option 1. launches a selenium standalone server. this is helpful if
// you launch it with "webdriver-manager start"
// seleniumAddress: "http://localhost:4444/wd/hub",
//
// option 2. launch browser directly using browser binaries
// directConnect: true,
//
// option 3. do not include either seleniumAddress or directConnect
// and this option will launch the selenium standalone server using
// your ip address.
//
// option 4: launch with saucelabs or browserstack options
}
This file relates to this one where you define your config, set capabilities only for travis and export the config.
'use strict';
// Protractor configuration
var config = {
specs: ['modules/*/tests/e2e/*.js']
};
if (process.env.TRAVIS) {
config.capabilities = {
browserName: 'firefox'
};
}
exports.config = config;

Related

inject is not defined - CodeceptJs and CucumberJs

It's my first time using CodeceptJs and I'm struggling to run my feature file as the IDE asks me to implement steps for my scenario but this is already done, so I feel it may be searching for them somewhere other than the specified under the codecept.conf.js file?
When I run npx codeceptjs gherkin:steps or snippets on the terminal I get this message saying Could not include object Step Definition from ./step_definitions/steps.js from module '/Users/myUser/IdeaProjects/codeceptjs_webdriver/step_definitions/steps.js' The "from" argument must be of type string. Received undefined .
I then move the step_definitions folder to inside features as read that this would be the default location for these and now get an inject is not defined error, which may be the actual cause for the issue I'm getting, but not sure what to do to fix it.
I've tried on IntelliJ Ultimate, Webstorm and VSCode but get the same on all of them.
basic.feature
Feature: Business rules
In order to achieve my goals
As a persona
I want to be able to interact with a system
Scenario: do something
Given I have a defined step
steps.js
const {Given} = require('cucumber');
const {I} = inject();
Given(/^I have a defined step$/, function () {
I.amOnPage('/');
});
codecept.conf.js
exports.config = {
output: './output',
helpers: {
WebDriver: {
url: 'https:www.google.com',
browser: 'chrome'
}
},
include: {
I: './steps_file.js'
},
mocha: {},
bootstrap: null,
teardown: null,
hooks: [],
gherkin: {
features: './features/*.feature',
steps: ['./step_definitions/steps.js']
},
plugins: {
screenshotOnFail: {
enabled: true
},
pauseOnFail: {},
retryFailedStep: {
enabled: true
},
tryTo: {
enabled: true
}
},
tests: './*_test.js',
name: 'codeceptjs_webdriver'
}
package.json
{
"name": "codeceptjs_webdriver",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"codeceptjs": "^3.0.0",
"cucumber": "^5.0.1"
},
"dependencies": {
"#codeceptjs/configure": "^0.6.0"
},
"description": ""
}
IntelliJ Ultimate 2020.2
And here my Github repo
Thank you very much.
It's working now and I've come back to update it here if useful to someone else.
Was able to keep the steps under step_definitions/steps folder (not the one inside the features folder). To fix the non implemented issue had to install the wdio dependency. In order for this to take effect properly through running npm install both node_modules and package-lock.json had to be deleted to be freshly regenerated.
updated package.json
{
"name": "codeceptjs_webdriver",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"test": "npx codeceptjs run"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {},
"dependencies": {
"#wdio/selenium-standalone-service": "^6.6.2",
"codeceptjs": "^2.6.8",
"codeceptjs-assert": "0.0.4",
"webdriverio": "6.3.6"
},
"description": ""
}
updated codecept.conf.js
exports.config = {
output: './output',
helpers: {
WebDriver: {
url: 'https://www.google.com',
browser: 'chrome'
}
},
include: {
I: './steps_file.js'
},
mocha: {},
bootstrap: null,
teardown: null,
hooks: [],
gherkin: {
features: './features/*.feature',
steps: ['./step_definitions/steps.js']
},
plugins: {
wdio: {
enabled: true,
services: ['selenium-standalone']
// additional config for service can be passed here
},
screenshotOnFail: {
enabled: true
},
pauseOnFail: {},
retryFailedStep: {
enabled: true
},
},
tests: './*_test.js',
name: 'codeceptjs_webdriver'
}

Webdriver-manager error: Unable to create session with *my config*

I run into the following problem after updating webdriver-manager:
E/launcher - SessionNotCreatedError: Unable to create session from
my config is printed here
webdriver-manager Version: 12.1.5
Node Version: 10.15.3
Protractor Version: 5.4.2
Browser(s): Chrome
Operating System and Version: Win 7 / Ubuntu
This is my config file which worked for the last 1.5 years:
exports.config = {
"seleniumAddress": "http://localhost:4444/wd/hub",
"seleniumPort": "4444",
"capabilities": {
"browserName": "chrome",
"unexpectedAlertBehaviour": "accept",
"perform": "ANY",
"version": "ANY",
"chromeOptions": {
"perfLoggingPrefs": {
"traceCategories": "blink.console,devtools.timeline,disabled-by-default-devtools.timeline,toplevel,disabled-by-default-devtools.timeline.frame,benchmark"
},
"prefs": {
"credentials_enable_service": false
},
"args": ["--headless", "--window-size=800,1080", "--disable-blink-features=BlockCredentialedSubresources", "--no-sandbox", "--test-type=browser", "--disable-dev-shm-usage", "--enable-gpu-benchmarking", "--enable-thread-composting" , "--start-maximized"]
},
"loggingPrefs": { "performance": "ALL" }
},
"jasmineNodeOpts": {
"showColors": true,
"defaultTimeoutInterval": 9999999
},
"allScriptsTimeout": 200000,
"params": {
"perf": {
"selenium": { "protocol": "http:", "slashes": true, "auth": null, "host": "localhost:4444", "port": 4444, "hostname": "localhost", "hash": null, "search": null, "query": null, "pathname": "/wd/hub", "path": "/wd/hub", "href": "http://localhost:4444/wd/hub" },
"browsers": [{
"browserName": "chrome",
"chromeOptions": {
"perfLoggingPrefs": {
"traceCategories": "blink.console,devtools.timeline,disabled-by-default-devtools.timeline,toplevel,disabled-by-default-devtools.timeline.frame,benchmark"
},
"args": ["--headless", "--disable-gpu", "--disable-blink-features=BlockCredentialedSubresources", "--no-sandbox", "--test-type=browser", "--disable-dev-shm-usage"]
},
"loggingPrefs": { "performance": "ALL" }
}],
"debugBrowser": false,
"actions": ["scroll"],
"metrics": ["TimelineMetrics", "ChromeTracingMetrics", "RafRenderingStats", "NetworkTimings", "NetworkResources"],
"metricOptions": {}
},
"warmup": false,
"agilar" : false
}
}
I know the file is a mess and it's more or less googled together, but it worked. Can you point me to what is causing this problem?
Is selenium server up and running at default address
"http://localhost:4444/wd/hub" . If it's not , start it by running : webdriver-manager start. Assuming you have webdriver-manager installed already.
Also I dont think you need to define seleniumPort when you have selenium address property given already in config. So remove this property "seleniumPort": "4444" from config.

Npm Publish Issue - Artifactory

I am publishing an npm library to an npm repo on artifactory. The library is built using angular and the dist folder and package.json looks correct. When publishing, the request it's self is published but not the actual artifact.
All i see on artifactory is a single file and not a folder containing my package
Running
npm publish
Package.json
{
"name": "#abce/embedded-auth",
"version": "1.0.0-dev.0",
"main": "bundles/abce-auth.umd.js",
"module": "fesm5/abce-auth.js",
"es2015": "fesm2015/abce-auth.js",
"esm5": "esm5/abce-auth.js",
"esm2015": "esm2015/abce-auth.js",
"fesm5": "fesm5/abce.js",
"fesm2015": "fesm2015/abce-auth.js",
"typings": "abce-auth.d.ts",
"metadata": "abce-auth.metadata.json",
"sideEffects": false,
"dependencies": {
"tslib": "^1.9.0"
}
}
What actually gets published to artifactory in a single file.
{
"_id": "#abce/embedded-auth",
"name": "#abce/embedded-auth",
"dist-tags": {
"latest": "1.0.0-dev.1"
},
"versions": {
"1.0.0-dev.1": {
"name": "#abce/embedded-auth",
"version": "1.0.0-dev.1",
"main": "bundles/abce-auth.umd.js",
"module": "fesm5/abce-auth.js",
"es2015": "fesm2015/abce-auth.js",
"esm5": "esm5/abce-auth.js",
"esm2015": "esm2015/abce-auth.js",
"fesm5": "fesm5/abce-auth.js",
"fesm2015": "fesm2015/abce-auth.js",
"typings": "abce-auth.d.ts",
"metadata": "abce-auth.metadata.json",
"sideEffects": false,
"dependencies": {
"tslib": "^1.9.0"
},
"readme": "ERROR: No README data found!",
"_id": "#abce/embedded-auth#1.0.0-dev.1",
"_npmVersion": "6.4.1",
"_nodeVersion": "10.15.3",
"_npmUser": {
"name": "deployment",
"email": "bob#bob.ie"
},
"maintainers": [
{
"name": "deployment",
"email": "bob#bob.ie"
}
],
"dist": {
"integrity": "sha512-rpTN1sMpwnMwehzWUqbV+zElzaOlF5ekQRCQMncy6c+i4TAp5jbBobvzrhgl0ORqHgJn3Eo+EcrRgYLSjV7MdQ==",
"shasum": "71f654dd5fddb20a9d5063171d5293424a4271c7",
"tarball": "http://abce.jfrog.io/abce/internal-npm-dev/#abce/embedded-auth/-/#abce/embedded-auth-1.0.0-dev.1.tgz"
}
}
},
"readme": "ERROR: No README data found!",
"maintainers": [
{
"name": "deployment",
"email": "bob#bob.ie"
}
],
"_attachments": {
"#abce/embedded-auth-1.0.0-dev.1.tgz": {
"content_type": "application/octet-stream",
"data": "correctly populated tarball base64 data here. I checked it and it is correct",
"length": 12092
}
}
}
Expect:
I would expect the package to be parsed from the request and the package published correctly
Actual:
The put request data from the npm publish command is published as a file
npm version: 6.9.0
node version: v12.3.1(has also been run with 10.15.3)
Any ideas?
Please check the registry URL that you are using from npm, if it doesn't include /api/npm - it is invalid.
Wrong URL: https://domain/artifactory/some-directory/.
Valid URL: https://domain/artifactory/api/npm/some-directory/.

How can I change test suite name for Botium test using botium bindings. Currenlty it is coming default name

I am using botium bindings with mocha test runner and mochawesome reporter. I want to change default test suite name coming in mochaawesome report.
I have tried by modifying botium.spec file by below commna
-didnt work
I have tried to set up test suitename in envs in botium.json file. didnt work
1) botium.spec.js
const bb = require('botium-bindings')
bb.helper.mocha().setupMochaTestSuite('Demo Test suite')
2) botium.json
{
"botium": {
"Capabilities": {
"PROJECTNAME": "Test chatbot",
"CONTAINERMODE": "watson",
"WATSON_APIKEY" : "xxx",
"WATSON_WORKSPACE_ID": "xxx",
"WATSON_URL" : "https://gateway-lon.watsonplatform.net/assistant/api",
"WATSON_COPY_WORKSPACE" : true
},
"Sources": {},
"Envs": {
"BOTIUM_TESTSUITENAME" : "Demo Test suite"
}
}
}
3) package.json
{
"name": "Botium_Test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "mocha --reporter mochawesome --reporter-options \"code=false,reportTitle=Digital CityCool,inline=true,overwrite=false\" --exit spec",
"mocha": "mocha spec"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"botium-bindings": "^2.0.10",
"botium-connector-echo": "latest",
"botium-connector-watson": "0.0.5",
"mocha": "latest",
"mochawesome": "^3.1.1"
},
"botium": {
"convodirs": [
"spec\\convo"
],
"expandConvos": true,
"expandUtterancesToConvos": false
}
}
mocha report test suite name coming as 'Botium Test Suite for Botium_Test'
I want test suite name as defined in botium.json file
Your trial #1 was pretty close. Use this in the botium.spec.js:
const bb = require('botium-bindings')
bb.helper.mocha().setupMochaTestSuite({ name: 'Demo Test suite' })

Unable to resolve 'react-navigation'

Am trying out react-native and get below error, when I install and try to use react-navigation (import {StackNavigator} from 'react-navigation';).
Error
I use the following command to install "react-navigation" : npm install --save react-navigation
On running above command I get 'react-navigation' folder under node_modules folder, with just a single file (package.json). Below is the content of the file:
{
"_args": [
[
{
"raw": "react-navigation#0.0.0",
"scope": null,
"escapedName": "react-navigation",
"name": "react-navigation",
"rawSpec": "0.0.0",
"spec": "0.0.0",
"type": "version"
},
"/Users/rakesh-1812/Documents/REACT_JS/SimpleApp"
]
],
"_from": "react-navigation#0.0.0",
"_id": "react-navigation#0.0.0",
"_inCache": true,
"_location": "/react-navigation",
"_nodeVersion": "4.2.1",
"_npmOperationalInternal": {
"host": "packages-12-west.internal.npmjs.com",
"tmp": "tmp/react-navigation-0.0.0.tgz_1459892254509_0.1584461957681924"
},
"_npmUser": {
"name": "ericvicenti",
"email": "ericvicenti#gmail.com"
},
"_npmVersion": "2.14.7",
"_phantomChildren": {},
"_requested": {
"raw": "react-navigation#0.0.0",
"scope": null,
"escapedName": "react-navigation",
"name": "react-navigation",
"rawSpec": "0.0.0",
"spec": "0.0.0",
"type": "version"
},
"_requiredBy": [
"#USER",
"/"
],
"_resolved": "https://registry.npmjs.org/react-navigation/-/react-navigation-0.0.0.tgz",
"_shasum": "1e0f865235cdb4d4aa8086484fd3690ff73df553",
"_shrinkwrap": null,
"_spec": "react-navigation#0.0.0",
"_where": "/Users/rakesh-1812/Documents/REACT_JS/SimpleApp",
"dependencies": {},
"description": "Coming Soon",
"devDependencies": {},
"directories": {},
"dist": {
"shasum": "1e0f865235cdb4d4aa8086484fd3690ff73df553",
"tarball": "https://registry.npmjs.org/react-navigation/-/react-navigation-0.0.0.tgz"
},
"maintainers": [
{
"name": "ericvicenti",
"email": "ericvicenti#gmail.com"
}
],
"name": "react-navigation",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"scripts": {},
"version": "0.0.0"
}
Can someone please help me resolve the issue. Thanks in advance.
React navigation is still in beta. It works for me when I use the command:
npm install --save react-navigation#1.0.0-beta.7
This is the latest release. https://github.com/react-community/react-navigation/releases
You must stop your node server and start it again.
Do it:
sudo lsof -n -i4TCP:8081 | grep LISTEN
It will listen of the services that are running on port 8081. By default, react native server runs on it. Then, execute the command below to kill the server process.
kill -9 <cma process id>
Finally, run your project again with
react-native run-ios
on the project folder
I was unable to install react-native, tried everything from the internet. Using Yarn instead of npm resolved the problem.
Try installing react-navigation stack, npm i react-navigation-stack. Then import {createStackNavigator} from 'react-navigation-stack'
Stop the server and run your project again.