Overlay-navbar using npm overlay-navbar module? - reactjs

I am Creating a overlay-navbar using npm overlay-navbar module
https://www.npmjs.com/package/overlay-navbar
But I am getting a error:
the requested module './io5' contains conflicting star exports for the names 'iologoandroid', 'iologoangular',
'iologoapple', 'iologobitbucket', 'iologobitcoin', 'iologobuffer',
'iologochrome', 'iologoclosedcaptioning', 'iologocodepen', 'iologocss3', 'iologodesignernews', 'iologodribbble',
'iologodropbox', 'iologoeuro', 'iologofacebook', 'iologoflickr',
'iologofoursquare', 'iologogithub', 'iologogoogle', 'iologohackernews', 'iologohtml5', 'iologoinstagram',
'iologoionic', 'iologoionitron', 'iologojavascript', 'iologolinkedin',
'iologomarkdown', 'iologonosmoking', 'iologonodejs', 'iologonpm', 'iologooctocat',
'iologopinterest', 'iologoplaystation', 'iologopython', 'iologoreddit', 'iologorss', 'iologosass', 'iologoskype',
'iologoslack', 'iologosnapchat', 'iologosteam', 'iologotumblr', 'iologotux', 'iologotwitch', 'iologotwitter',
'iologousd', 'iologovimeo', 'iologovk', 'iologowhatsapp',
'iologowindows', 'iologowordpress', 'iologoxbox', 'iologoxing', 'iologoyahoo', 'iologoyen', '
iologoyoutube' with the previous requested module './io'
what can I do to resolve this issue ?
Here is my package.json file :
{
"name": "frontend",
"version": "0.1.0",
"private": true,
"dependencies": {
"#testing-library/jest-dom": "^5.16.1",
"#testing-library/react": "^12.1.2",
"#testing-library/user-event": "^13.5.0",
"axios": "^0.24.0",
"bootstrap": "^5.1.3",
"overlay-navbar": "^1.1.1",
"react": "^17.0.2",
"react-alert": "^7.0.3",
"react-alert-template-basic": "^1.0.2",
"react-bootstrap": "^2.0.3",
"react-dom": "^17.0.2",
"react-helmet": "^6.1.0",
"react-icons": "^4.3.1",
"react-redux": "^7.2.6",
"react-router-dom": "^6.2.1",
"react-scripts": "5.0.0",
"redux": "^4.1.2",
"redux-devtools-extension": "^2.13.9",
"redux-thunk": "^2.4.1",
"web-vitals": "^2.1.2"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"webpack": "^5.65.0"
}
}
I have tried reinstalling modules but it does'nt work

I think this issue is related to react-icons and webpack 5.
Someone has already posted a similar issue in react-icons github https://github.com/react-icons/react-icons/issues/514
and you're using create-react-app version 5 which use webpack 5 as module bundler. Nothing we can really do until react-icons updating their library regarding this (if you insist on using version 5).
Meanwhile, the easiest way you can downgrade your webpack to version 4 by downgrading create-react-app.
Try this command:
npm i react-scripts#4
**note: I notice too that you're using react-router-dom ^6.2.1, you should downgrade this too as overlay-navbar doesn't support that version.
Try this command:
npm i react-router-dom#5

I have found a very simple but effective solution, Problem is offcourse with React Icons as there is some kind of bug in io folder, so all you need to do is
npm uninstall react-icons
then install version 3 by running
npm install react-icons#3
boom this worked in my case. Also i suggest you to do the same for react-router-dom because there is an issue with Route in it.

Well, if your are concerned about using overlay-navbar then there is a way of using it without degrading react Scripts and react router.
Overlay-Nav-bar doesn't uses any icons from io and io5 folders so follow the following steps.
-Go to node modules -> react icons folder
Then Go to add.js file and then comment out this line // export * from './io5';
Then go to all.d.ts file and comment out the same file.
`
// THIS FILE IS AUTO GENERATED
export * from './fa';
export * from './io';
// export * from './io5';
export * from './md';
export * from './ti';
export * from './go';
export * from './fi';
export * from './gi';
export * from './wi';
export * from './di';
export * from './ai';
export * from './bs';
export * from './ri';
export * from './fc';
export * from './gr';
export * from './hi';
export * from './si';
export * from './im';
export * from './bi';
export * from './cg';
export * from './vsc';
`
Restart Your Development server. It should work Now

Related

Chrome Extension Service Worker not Supporting Importing Other JS Files or NPM Packages

I am developing a Chrome Extension with React. In my service worker file, background.js, I need to import another JS file, which for simplicity, only exports an empty {} for now.
background.js
import store from './testImport';
console.log("Hello Service Worker.")
testImport.js
export default {}
but with no success. I get this error:
I searched for my problem, and most solutions suggested to add "type": "module" to manifest.json:
"background": {
"service_worker": "background.js",
"type": "module"
},
I did that and I got a new very vague error message:
An unknown error occurred when fetching the script.
I tried replacing the import with a require:
const store = require('./testImport');
console.log("Hello Service Worker.")
But these results in another error:
Uncaught ReferenceError: require is not defined
Anyway, I don't think require is the solution anyway. Import statements should work, as I've seen them used by others within service worker files and it worked for them. The problem is there are quite a few resources on the internet on this issue and I feel I've exhuasted them all.
Why don't import statements work in my service worker file? Am I doing something wrong?
UPDATE
#wOxxOm's suggestion to add ./ and .js when importing other JS modules works!
However, I need to import NPM packages into the service worker, and I get this error:
Uncaught TypeError: Failed to resolve module specifier "axios".
Relative references must start with either "/", "./", or "../"
package.json
{
"name": "app",
"version": "0.1.0",
"private": true,
"dependencies": {
"#reduxjs/toolkit": "^1.8.3",
"#testing-library/jest-dom": "^5.16.4",
"#testing-library/react": "^13.3.0",
"#testing-library/user-event": "^13.5.0",
"#types/jest": "^27.5.2",
"#types/node": "^16.11.41",
"#types/react": "^18.0.14",
"#types/react-dom": "^18.0.5",
"axios": "^0.27.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-redux": "^8.0.2",
"react-scripts": "5.0.1",
"react-scroll": "^1.8.7",
"typescript": "^4.7.4",
"watch": "^1.0.2",
"web-vitals": "^2.1.4",
"webext-redux": "^2.1.9"
},
"scripts": {
"start": "react-scripts start",
"build": "INLINE_RUNTIME_CHUNK=false react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"watch": "watch 'npm run build' src"
},
"watch": {
"build": "src/"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"#types/chrome": "0.0.193",
"#types/react-scroll": "^1.8.3",
"autoprefixer": "^10.4.7",
"npm-watch": "^0.11.0",
"postcss": "^8.4.14",
"tailwindcss": "^3.1.3"
}
}
When you run npm command. NPM replace package name to real path.
You need to just find real path so that chrome browser will find it.
Real path like this:
/node_modules/pkg-name/dist/main.js
Method 1.
Create path.js file and add this line.
const fullPath = await import.meta.resolve("package_name");
const path = fullPath?.match(/(\/node_modules.*)/)[0];
console.log(path);
then add this line inside scripts in package.json and run npm run path.
"path": "node --experimental-import-meta-resolve path.js",
copy console output text. Replace package name with this copied path.
Method 2
Install other npm package to find and replace
npm packages' virtual path to real path so that chrome browser will find it.
Install Path-fixxer
Add this line in path.js
import setAllPkgPath from "path-fixxer";
setAllPkgPath();
then run command : npm run path.
Now open browser to test it.
Note: It only work with esm npm packages.

Failed to initialize watch plugin "node_modules/jest-watch-typeahead/filename.js":

I am using react with typescript in my project and also I am doing snapshot testing but when I run npm test command in vscode terminal I am getting error which I have attached in the attachement.
could you please let me know what should I do so that all the test case run successfully or any other thing I need to configure
Here is my package.json
{
"name": "vcc-collaboration-app",
"version": "0.1.0",
"private": true,
"dependencies": {
"#fluentui/react": "^8.42.1",
"#fluentui/react-file-type-icons": "^8.5.6",
"#testing-library/jest-dom": "^5.15.0",
"#testing-library/react": "^11.2.7",
"#testing-library/user-event": "^12.8.3",
"#types/react-test-renderer": "^17.0.1",
"ag-grid-community": "^26.2.0",
"ag-grid-react": "^26.2.0",
"axios": "^0.24.0",
"babel-jest": "^26.6.0",
"jest": "^26.6.0",
"jest-watch-typeahead": "^1.0.0",
"moment": "^2.29.1",
"node-sass": "^6.0.1",
"react": "^17.0.2",
"react-bootstrap": "^2.0.2",
"react-dom": "^17.0.2",
"react-dropzone": "^11.4.2",
"react-grid": "^4.0.4",
"react-icons": "^4.3.1",
"react-router-dom": "^5.0.0",
"react-scripts": "4.0.3",
"react-test-renderer": "^17.0.2",
"vcc-ui": "^2.11.0",
"web-vitals": "^1.1.2"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"#types/jest": "^27.0.3",
"#types/node": "^16.11.7",
"#types/react": "^17.0.35",
"#types/react-dom": "^17.0.11",
"#types/react-dropzone": "^5.1.0",
"#types/react-router": "^5.1.17",
"#types/react-router-dom": "^5.3.2",
"typescript": "^4.5.2"
}
}
EngineeringArea.test.tsx
import React from "react";
import * as ShallowRenderer from "react-test-renderer/shallow";
import EngineeringArea from "./EngineeringArea";
describe("EngineeringArea Screen", () => {
it("EngineeringArea Screen renders correctly", () => {
const renderer = ShallowRenderer.createRenderer();
const component = renderer.render(<EngineeringArea />);
expect(component).toMatchSnapshot();
});
});
You need to install specifically v0.6.5 of jest-watch-typeahead
npm i -D --exact jest-watch-typeahead#0.6.5
Had this error come up. My answer was using nvm to switch from node's current release (my system default) to its LTS (16.14.0) with nvm use 16
Also got this error message when trying to test. Changing node version worked for me. Here is link to the article:
https://github.com/facebook/create-react-app/issues/11792
Last answer was wrong. Here's the correct answer. https://github.com/facebook/create-react-app/issues/11043#issuecomment-942472592
In my case with Vite-React and with Create React App, works:
You need to install specifically v0.6.5 of jest-watch-typeahead
npm i -D --exact jest-watch-typeahead#0.6.5
Thank you Matt
I faced this issue while I was trying to create a new React Application using CRA with npx.
I followed what Matt suggested in his answer but jest started throwing an error saying, it's better to remove any babel-jest dependency, which is weird but I guess jest-watch-typehead` uses babel maybe (it's a wild guess, I have not checked).
Anyway, here's what I did based on the suggestion I got on console from the error thrown by babel-jest.
Removed package-lock.json file.
Removed node_modules/.
Did a fresh npm i.
I ran my tests again and got an error for not importing React in App.test.js, so I simply imported and it worked.

create-react-app MaterialUI Error: Invalid hook call

I want to do Create-react-app and use Material UI, but I get a Hooks Error.
Am I missing something else?
This is an error statement.
Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
You might have mismatching versions of React and the renderer (such as React DOM)
You might be breaking the Rules of Hooks
You might have more than one copy of React in the same app
See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.
I did the following.
$ npx create-react-app my-app --template typescript
$ npm install #mui/material
$ npm install #mui/icons-material
package.json
{
"name": "muitest",
"version": "0.1.0",
"private": true,
"dependencies": {
"#mui/icons-material": "^5.2.1",
"#mui/material": "^5.2.3",
"#testing-library/jest-dom": "^5.16.1",
"#testing-library/react": "^11.2.7",
"#testing-library/user-event": "^12.8.3",
"#types/jest": "^26.0.24",
"#types/node": "^12.20.37",
"#types/react": "^17.0.37",
"#types/react-dom": "^17.0.11",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "4.0.3",
"typescript": "^4.5.2",
"web-vitals": "^1.1.2"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
App.tsx
import React from 'react';
import './App.css';
import GitHubIcon from '#mui/icons-material/GitHub';
function App() {
return (
<div className="App">
<GitHubIcon />
</div>
);
}
export default App;
https://create-react-app.dev/docs/adding-typescript/
https://github.com/mui-org/material-ui
please go through this both link, u need to add few packages then it will work.
npx create-react-app my-app --template typescript
npm install #mui/material #emotion/react #emotion/styled #types/material-ui
for typescript we need to install few package #types packages.

Im have a Typescript Problem which already asked few persons, and many got solution in upgrade version. But not Working for me

D:/.../../node_modules/#reduxjs/toolkit/dist/configureStore.d.ts
TypeScript error in D:/.../.../node_modules/#reduxjs/toolkit/dist/configureStore.d.ts(1,13):
'=' expected. TS1005
1 | import type { Reducer, ReducersMapObject, Middleware, Action, AnyAction, StoreEnhancer, Store, Dispatch, PreloadedState, CombinedState } from 'redux';
| ^
2 | import type { EnhancerOptions as DevToolsOptions } from './devtoolsExtension';
3 | import type { ThunkMiddlewareFor, CurriedGetDefaultMiddleware } from './getDefaultMiddleware';
4 | import type { DispatchForMiddlewares, NoInfer } from './tsHelpers';
I have tried mostly solutions like upgrade typescript which is 4.4.4 and node 14
this is Package.json I can share further information if need
{
"name": "project9a-shopping-cart-with-redux",
"version": "0.1.0",
"private": true,
"dependencies": {
"#reduxjs/toolkit": "^1.4.0",
"#testing-library/jest-dom": "^4.2.4",
"#testing-library/react": "^9.3.2",
"#testing-library/user-event": "^7.1.2",
"#types/classnames": "^2.2.10",
"#types/jest": "^24.0.0",
"#types/node": "^12.0.0",
"#types/react": "^16.9.0",
"#types/react-dom": "^16.9.0",
"#types/react-redux": "^7.1.9",
"#wellyshen/use-web-animations": "^0.5.5",
"classnames": "^2.2.6",
"history": "^5.0.0",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-icons": "^3.11.0",
"react-redux": "^7.2.1",
"react-router-dom": "^6.0.0-beta.0",
"react-scripts": "3.4.3",
"yarn": "^1.22.17"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"typescript": "^4.4.4"
}
}
H3AR7B3A7 yes you guess right, I were downloaded someone code from github and run npm install so that specific software and dependencies auto install to them, But somehow in my PC typescript 4.4.4 was globally install and code on github was 3.7.7 but after npm intall i'm tried to manually update package.json 4.4.4 again and run npm install again even it was showing with tsc -v that this folder have 4.4.4 but I hope internally system was mixing things up.
So I try same process in another folder but this time before run npm install i'm changed 3.7.7 to 4.4.4 and run npm install, work fine after that

Deploying react app to heroku giving H10 error code

I've created a react app using create-react-app.It is working well in my local server.But when I tried to deploy it to heroku it is crashing.I don't know why it is crashing.
In heroku logs --tail its showing error code=H10 desc=App crashed.I searched about this issue and nothing helpful for me.
My question is similar to this question : React app runs locally, crashes when on Heroku error code=H10
But I'm unable to understand the solution they given.
My package.json file is as follows:
{
"name": "lets-chat",
"version": "0.1.0",
"private": true,
"dependencies": {
"#fortawesome/fontawesome-svg-core": "^1.2.28",
"#fortawesome/free-brands-svg-icons": "^5.13.0",
"#fortawesome/free-regular-svg-icons": "^5.13.0",
"#fortawesome/free-solid-svg-icons": "^5.13.0",
"#fortawesome/react-fontawesome": "^0.1.9",
"#testing-library/jest-dom": "^4.2.4",
"#testing-library/react": "^9.5.0",
"#testing-library/user-event": "^7.2.1",
"dotenv": "^8.2.0",
"firebase": "^7.14.0",
"moment": "^2.24.0",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-router-dom": "^5.1.2",
"react-scripts": "3.4.1"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
I don't know what's wrong in this file.Should I make any changes in this file to get my problem solved?
heroku logs --tail gave the report as follows:
Check out this link (in case none of the solutions from that other post helped your case): https://dev.to/webdevraj/deploy-a-react-app-on-heroku-the-right-way-5efo
Pay attention to #6 where they mention the buildpack.
When using create-react-app and deploying to
dont delete the favicon.ico and manifest.json
also in package.json above scripts insert "engines": {
"npm": "6.x",
"node": "12.x"
},
//NOTE CHECK YOUR NODE AND NPM VERSIONS BY TYPING npm -v and node -v for accurate versions//
In heroku after heroku create command, go to heroku and change buildback under settings to https://github.com/mars/create-react-app-buildpack
Dont add other scripts or change the start, build scripts!
This should clear all h10 errors when deploying to heroku, if they dont i suggest you create a new directory and copy your files there and start over, this link is a great guide to deploy
https://dev.to/smithmanny/deploy-your-react-app-to-heroku-2b6f
I also had same issue. I could figure out it is something to do with react version.
I changed the version and it worked. Update your version in package.json and see if it works.
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-router-dom": "^5.1.2",
"react-scripts": "3.2.0"

Resources