Naming collision in react native app start - javascript

I'm using the out-of-the box react native framework to try to build a new app.
i used the following commands ind CMD (Windows 10).
node -v:
v8.12.0
npm -v:
6.4.1
mkdir react-native-workspace
cd react-native-workspace
npm install -g create-react-native-app
create-react-native-app Exercise2
cd Exercise2
npm start
ERROR 12:42 (node:15564) UnhandledPromiseRejectionWarning: Error: jest-haste-map: #providesModule naming collision: Duplicate module
name: my-new-project Paths:
C:\Users\wp_99\Dokumenter\react-native-workspace\Exercise2\package.json
collides with
C:\Users\wp_99\Documents\react-native-workspace\Exercise2\package.json
This error is caused by a #providesModule declaration with the same
name across two different files.
at setModule (C:\Users\wp_99\Documents\react-native-workspace\Exercise2\node_modules\metro\node_modules\jest-haste-map\build\index.js:462:17)
at workerReply (C:\Users\wp_99\Documents\react-native-workspace\Exercise2\node_modules\metro\node_modules\jest-haste-map\build\index.js:512:9)
at
at process._tickCallback (internal/process/next_tick.js:189:7) ERROR 12:42 (node:15564) 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(). (rejection id: 2) (node:15564)
[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.

It's a bug in the metro-bundler. You should create rn-cli.config.js and add this configuration to it:
For react-native>=0.57
const blacklist = require('metro-config/src/defaults/blacklist');
module.exports = {
resolver:{
blacklistRE: blacklist([
/nodejs-assets\/.*/,
/android\/.*/,
/ios\/.*/
])
},
};
react-native < 0.57
const blacklist = require('metro/src/blacklist');
module.exports = {
getBlacklistRE: function() {
return blacklist([
/nodejs-assets\/.*/,
/android\/.*/,
/ios\/.*/
]);
},
};
You can read more here.

I've added the following to rn-cli.config.js
const blacklist = require('metro-config/src/defaults/blacklist');
module.exports = {
resolver: {
blacklistRE: blacklist([
/node_modules\/.*\/node_modules\/react-native\/.*/,
])
},
};

Related

SessionNotCreatedError: Expected browser binary location, but unable to find binary in default location, no 'moz:firefoxOptions.binary'

When I run my test code locally, it concludes successfully, but when I try to connect the pipeline, I get the below error:
+ node login.js
(node:74) UnhandledPromiseRejectionWarning: SessionNotCreatedError: Expected browser binary location, but unable to find binary in default location, no 'moz:firefoxOptions.binary' capability provided, and no binary flag set on the command line
at Object.throwDecodedError (/opt/atlassian/pipelines/agent/build/node_modules/selenium-webdriver/lib/error.js:514:15)
at parseHttpResponse (/opt/atlassian/pipelines/agent/build/node_modules/selenium-webdriver/lib/http.js:519:13)
at /opt/atlassian/pipelines/agent/build/node_modules/selenium-webdriver/lib/http.js:441:30
at processTicksAndRejections (internal/process/task_queues.js:97:5)
From: Task: WebDriver.createSession()
at Function.createSession (/opt/atlassian/pipelines/agent/build/node_modules/selenium-webdriver/lib/webdriver.js:769:24)
at Function.createSession (/opt/atlassian/pipelines/agent/build/node_modules/selenium-webdriver/firefox/index.js:521:41)
at createDriver (/opt/atlassian/pipelines/agent/build/node_modules/selenium-webdriver/index.js:170:33)
at Builder.build (/opt/atlassian/pipelines/agent/build/node_modules/selenium-webdriver/index.js:645:16)
at login (/opt/atlassian/pipelines/agent/build/tests/login.js:16:58)
(node:74) 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:74) [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.
My pipeline.yml file:
script:
- ls
- cd tests
- ls
- yarn install
- chmod +x geckodriver
- export PATH="$PATH:~/.tests/geckodriver"
- echo $PATH
- ls
- node login.js
My login.js code:
const { Builder, By, Key } = require('selenium-webdriver');
const firefox = require('selenium-webdriver/firefox');
function sleep(time) {
return new Promise(resolve => setTimeout(resolve, time));
}
const login = async () => {
let driver = await new Builder().forBrowser('firefox').build();
await driver.get('https:www.google.com/login');
driver.close();
};
I've tried:
export PATH="/usr/local/bin:$PATH"
export PATH="$PATH:/usr/local/bin"
export PATH="$PATH:/geckodriver"

IPFSAccessController.save ERROR: Error: Deprecated, use .toString()

i'm only trying to launch the exemple of the app kit OrbitDB which is :
import OrbitDB from "orbit-db";
import IPFS from "ipfs";
async function main () {
// Create IPFS instance
const ipfsOptions = { repo : './ipfs', }
const ipfs = await IPFS.create(ipfsOptions)
// Create OrbitDB instance
const orbitdb = await OrbitDB.createInstance(ipfs)
// Create database instance
const db = await orbitdb.keyvalue('ipfs_db')
}
main()
you can find it here : https://github.com/dappkit/aviondb#using-nodejs
but the problem is when i launch it, i got these errors :
Swarm listening on /ip4/127.0.0.1/tcp/4002/p2p/12D3KooWM7D9NdMhtxyiWiKH4XVpuZW5oDu9MbWxFmEzLsG9UynM
Swarm listening on /ip4/192.168.1.53/tcp/4002/p2p/12D3KooWM7D9NdMhtxyiWiKH4XVpuZW5oDu9MbWxFmEzLsG9UynM
Swarm listening on /ip4/127.0.0.1/tcp/4003/ws/p2p/12D3KooWM7D9NdMhtxyiWiKH4XVpuZW5oDu9MbWxFmEzLsG9UynM
IPFSAccessController.save ERROR: Error: Deprecated, use .toString()
at CID.get toBaseEncodedString [as toBaseEncodedString] (/home/zar/Etna4/SmartContract/db_ipfs/node_modules/multiformats/cjs/src/cid.js:94:11)
at Object.writeCbor [as write] (/home/zar/Etna4/SmartContract/db_ipfs/node_modules/aviondb/node_modules/orbit-db-access-controllers/node_modules/orbit-db-io/index.js:62:14)
at async IPFSAccessController.save (/home/zar/Etna4/SmartContract/db_ipfs/node_modules/aviondb/node_modules/orbit-db-access-controllers/src/ipfs-access-controller.js:46:13)
at async Function.create (/home/zar/Etna4/SmartContract/db_ipfs/node_modules/aviondb/node_modules/orbit-db-access-controllers/src/access-controllers.js:68:20)
at async OrbitDB._determineAddress (/home/zar/Etna4/SmartContract/db_ipfs/node_modules/aviondb/node_modules/orbit-db/src/OrbitDB.js:331:37)
(node:8397) UnhandledPromiseRejectionWarning: Error: `undefined` is not supported by the IPLD Data Model and cannot be encoded
at undefinedEncoder (/home/zar/Etna4/SmartContract/db_ipfs/node_modules/#ipld/dag-cbor/cjs/index.js:47:9)
at objectToTokens (/home/zar/Etna4/SmartContract/db_ipfs/node_modules/cborg/cjs/lib/encode.js:175:20)
at Object (/home/zar/Etna4/SmartContract/db_ipfs/node_modules/cborg/cjs/lib/encode.js:149:9)
at objectToTokens (/home/zar/Etna4/SmartContract/db_ipfs/node_modules/cborg/cjs/lib/encode.js:184:10)
at Object (/home/zar/Etna4/SmartContract/db_ipfs/node_modules/cborg/cjs/lib/encode.js:149:9)
at objectToTokens (/home/zar/Etna4/SmartContract/db_ipfs/node_modules/cborg/cjs/lib/encode.js:184:10)
at encodeCustom (/home/zar/Etna4/SmartContract/db_ipfs/node_modules/cborg/cjs/lib/encode.js:214:18)
at Object.encode (/home/zar/Etna4/SmartContract/db_ipfs/node_modules/cborg/cjs/lib/encode.js:236:10)
at Object.encode (/home/zar/Etna4/SmartContract/db_ipfs/node_modules/#ipld/dag-cbor/cjs/index.js:85:41)
at put (/home/zar/Etna4/SmartContract/db_ipfs/node_modules/ipfs-core/src/components/dag/put.js:35:25)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:8397) 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: 2)
(node:8397) [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.
i seriously don't know what to do, i tried to clear the cache, to delete node_modules and package-lock.json, and do a npm install, but nothing changed, i got the same error, do you have any idea to fix this ?
This error clearly points to an incompatibility between IPFS and OrbitDB.
The latest version of js-ipfs that OrbitDB v0.26.1 supports is 0.55.4.
You should change the ipfs (or ipfs-core) version in your package.json to ^0.55.4.
Note: The upcoming OrbitDB v0.27, will support the latest IPFS version.

Errors with compiling Zig to wasm32-freestanding

I am trying to compile Zig functions to a freestanding WebAssembly module using the wasm32-freestanding target. The official documentation has a section explaining how to do this, but with a recent version of Zig (0.8.0) I get errors when trying to instantiate the resulting module with JavaScript.
// file: main.zig
export fn add(a: i32, b: i32) i32 {
return a +% b;
}
// file: test.js
WebAssembly.instantiate((function() {
const source = require("fs").readFileSync("main.o");
return new Uint8Array(source);
})(), { env: {} }).then(wasm => {
const add = wasm.instance.exports.add;
console.log(add(1, 2));
});
$ zig version
0.8.0
$ node --version
14.17.3
$ zig build-obj main.zig -target wasm32-freestanding -dynamic -OReleaseFast
$ wc -c main.o # the generated code has extension `.o` instead of `.wasm`
135
$ node test.js
(node:2449) UnhandledPromiseRejectionWarning: LinkError: WebAssembly.instantiate(): Import #0 module="env" function="__linear_memory" error: memory import must be a WebAssembly.Memory object
(Use `node --trace-warnings ...` to show where the warning was created)
(node:2449) 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:2449) [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.
Inspecting the generated wasm module shows that it attempts to import a value called __linear_memory from the scope env. Naturally this fails as I am not providing such an import. However, the example project zig-wasm-test includes a WASM module (compiled with an old version of Zig) which does not include these imports.
What am I doing wrong here? Should I just be providing a __linear_memory export to the module even though it isn't used?
You should try using build-lib instead of build-obj.

Invalid locator using Protractor and Cucumber

I'm trying to execude a code using protractor but i am obtaining this issue :
[12:48:45] I/direct - Using ChromeDriver directly...
..
(node:34588) UnhandledPromiseRejectionWarning: TypeError: Invalid locator
at Object.check [as checkedLocator] (C:\Users\karro\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\by.js:275:9)
at Driver.findElements (C:\Users\karro\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver.js:1041:18)
at C:\Users\karro\AppData\Roaming\npm\node_modules\protractor\built\element.js:159:44Error
at ElementArrayFinder.applyAction_ (C:\Users\karro\AppData\Roaming\npm\node_modules\protractor\built\element.js:459:27)
at ElementArrayFinder. [as sendKeys] (C:\Users\karro\AppData\Roaming\npm\node_modules\protractor\built\element.js:91:29)
at ElementFinder. [as sendKeys] (C:\Users\karro\AppData\Roaming\npm\node_modules\protractor\built\element.js:831:22)
at World. (C:\Users\karro\WebstormProjects\ProtractorTest\test\banking.ts:17:36)
(node:34588) 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:34588) [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.
(node:34588) UnhandledPromiseRejectionWarning: TypeError: Invalid locator
at Object.check [as checkedLocator] (C:\Users\karro\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\by.js:275:9)
at Driver.findElements (C:\Users\karro\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver.js:1041:18)
at C:\Users\karro\AppData\Roaming\npm\node_modules\protractor\built\element.js:159:44Error
at ElementArrayFinder.applyAction_ (C:\Users\karro\AppData\Roaming\npm\node_modules\protractor\built\element.js:459:27)
at ElementArrayFinder. [as sendKeys] (C:\Users\karro\AppData\Roaming\npm\node_modules\protractor\built\element.js:91:29)
at ElementFinder. [as sendKeys] (C:\Users\karro\AppData\Roaming\npm\node_modules\protractor\built\element.js:831:22)
at World. (C:\Users\karro\WebstormProjects\ProtractorTest\test\banking.ts:18:37)
(node:34588) 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: 2)
1 scenario (1 passed)
I have installed the next :
npm install -g protractor
npm install --save-dev protractor cucumber protractor-cucumber-framework chai chai-as-promised
npm install cucumber-html-reporter --save-dev
npm install mocha -g
npm install mocha --save-dev
And this is my code :
Login.feature:
Feature: Example
Scenario: Login Success
When I try to login with valid credentials
banking.ts:
let {defineSupportCode} = require('cucumber');
let chai = require('chai').use(require('chai-as-promised'));
let expect = chai.expect;
var { browser, by, element }= require ('protractor');
var {Given} = require('cucumber');
var {When} = require('cucumber');
var {Then} = require('cucumber');
var {setDefaultTimeout} = require('cucumber');
setDefaultTimeout(60 * 1000);
When('I try to login with valid credentials', function() {
browser.get('http://juliemr.github.io/protractor-demo/');
element(by.name=('first')).sendKeys('1234');
element(by.name=('second')).sendKeys('2356');
});
conf.js:
'use strict';exports.config = {directConnect: true,//Running chrome
Capabilities: { browserName: 'chrome'
},
specs: ['../features/*.feature'],//set framework options
framework: 'custom',
frameworkPath: require.resolve('protractor-cucumber-framework'), //just maximizing window before testing
onPrepare: function(){
browser.waitForAngularEnabled(false);
browser.driver.manage().window().maximize();
} ,//Create html report
"types": ["chai", "cucumber", "node"],
"typeRoots": [ "../node_modules/#types"],
onComplete: () => {
var reporter = require('cucumber-html-reporter');
var options = {
theme: 'bootstrap',
jsonFile: './results.json',
//output: './results.html',
reportSuiteAsScenarios: true,
launchReport: true,
metadata: {
"App Version":"0.3.2",
"Test Environment": "STAGING",
"Browser": "Chrome 54.0.2840.98",
"Platform": "Windows 10",
"Parallel": "Scenarios",
"Executed": "Remote"
},
output: './report/cucumber_report.html',
};
reporter.generate(options);
},//set cucumber options
cucumberOpts: {
require: ['../test/banking.ts'],
strict: true,
// format: [], //don't put 'Pretty' as it is depreciated
'dry-run': false,
compiler: [],
format: 'json:results.json', //make sure you are not using multi-capabilities
},
SELENIUM_PROMISE_MANAGER: false,
};
I have added also a screenshot about my project is done.
Could anyone help me? thank you in advance.

Mocha JUnit reporter UnhandledPromiseRejectionWarning

I'm trying to make this example work in my Azure Devops Pipeline.
https://mochajs.org/#getting-started
First I tried to have my own tests already but after I keep getting the following error I reverted to the basic example but still I'm getting this error:
mocha test --reporter mocha-junit-reporter
========================== Starting Command Output ===========================
"C:\windows\system32\cmd.exe" /D /E:ON /V:OFF /S /C "CALL "d:\a\_temp\3909d6a6-de56-4ad9-9fb2-b94c5529546b.cmd""
(node:2160) UnhandledPromiseRejectionWarning: TypeError: Cannot convert undefined or null to object
at Function.keys (<anonymous>)
at Object.help (C:\npm\prefix\node_modules\mocha\node_modules\yargs\lib\usage.js:240:22)
at Object.self.showHelp (C:\npm\prefix\node_modules\mocha\node_modules\yargs\lib\usage.js:432:15)
at Array.<anonymous> (C:\npm\prefix\node_modules\mocha\lib\cli\cli.js:53:13)
at Object.fail (C:\npm\prefix\node_modules\mocha\node_modules\yargs\lib\usage.js:41:17)
at C:\npm\prefix\node_modules\mocha\node_modules\yargs\lib\command.js:246:36
(node:2160) 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:2160) [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.
Finishing: Test Mocha
I've tried running it in both a windows and linux container but can't see any difference.
This is my file structure
index.html
app.js
package.json
style.css
readme.md
-test
test.js
This is the content of the package.json
{
"scripts": {
"test": "mocha"
}
}
This is the contact of the test\test.js file
var assert = require('assert');
describe('Array', function() {
describe('#indexOf()', function() {
it('should return -1 when the value is not present', function() {
assert.equal([1, 2, 3].indexOf(4), -1);
});
});
});
The html and app.js file are for now now interesting I assume because they aren't called anywhere.
Here is also the pipeline defenition:
pool:
name: Azure Pipelines
demands: npm
steps:
- task: Npm#1
displayName: 'npm install'
inputs:
verbose: false
- script: 'npm install --save-dev mocha'
displayName: 'Install Mocha'
- script: 'npm install --save-dev mocha-junit-reporter'
displayName: 'Install Reporter'
- script: |
npm i --save-dev chai
displayName: 'Install Chai'
- script: 'npm test'
displayName: 'Test Mocha'
continueOnError: true
- powershell: |
ls "$(System.DefaultWorkingDirectory)"
displayName: 'PowerShell Script'
- task: PublishTestResults#2
displayName: 'Publish Test Results **/test-results.xml'
inputs:
testResultsFiles: '**/test-results.xml'
condition: succeededOrFailed()
- task: ArchiveFiles#1
displayName: 'Archive files'
inputs:
rootFolder: '$(System.DefaultWorkingDirectory)'
includeRootFolder: false
archiveType: zip
- task: PublishBuildArtifacts#1
displayName: 'Publish Artifact: drop'
When I try to run it without the reporter then it gives an output and the tests are done, I just get this error when adding the reporter. I also tried to use the xunit reporter instead but then I get the same error.
What am I missing here? Anyone knows why I get this error and how I can prevent it?
I'm not much of a javascript code myself I'm more at home in other languages and mostly do this to setup automatic testing for other programmers.

Categories