Getting error in react after installing fontawesome through npm - javascript

i have installed fontawesome by following these steps by visiting their website.
npm i --save #fortawesome/fontawesome-svg-core
npm install --save #fortawesome/free-solid-svg-icons
npm install --save #fortawesome/react-fontawesome
and now am getting this error
./node_modules/react-scripts/node_modules/#pmmmwh/react-refresh-webpack-plugin/lib/runtime/RefreshUtils.js
Error: ENOENT: no such file or directory, open 'C:\Users\HP\Desktop\practice site\javascript\REACT\Codingworld\node_modules\react-scripts\node_modules#pmmmwh\react-refresh-webpack-plugin\lib\runtime\RefreshUtils.js'
Help me to solve my error

Please try this one. I hope to solve it. if it solves please comment on my answer.
install font-awesome for react

The error message says that it's looking for a file RefreshUtils.js in the directory C:\Users\HP\Desktop\practice site\javascript\REACT\Codingworld\node_modules\react-scripts\node_modules#pmmmwh\react-refresh-webpack-plugin\lib\runtime but doesn't find it.
This file is part of the npm package #pmmmwh/react-refresh-webpack-plugin.
It could be that you previously installed this package, or that this package is a dependency for another package you're using (e.g. react-scripts).
Your question doesn't include sufficient information, such as the content of your package.json file, and specifying which command is giving the error.
There could be various reasons causing the error:
Running the command from the wrong folder
In this case, navigate to the correct folder in your terminal, then run the command.
Issues in your dependencies
In this case, given that you have a package.json file in your project folder, reinstall all your dependencies:
Delete the node_modules folder and the package-lock.json file
Run npm cache clean
Run npm install
Given that you're running the command from the correct folder and your dependencies are up-to-date, the error should go away.

Related

Can't npm install local dependency

I've been using npm install react-financial-charts successfully. However, I want to include this package locally instead (for reasons), so I checked out the master branch of react-financial-charts from Github. I now have two folders:
C:\Users\user\projects\react-financial-charts // fresh checkout from Github
C:\Users\user\projects\myproject // my project
Inside of my project, my package.json contains:
"dependencies": {
"react-financial-charts": "file:C:/Users/user/projects/react-financial-charts"
}
npm run dev will now encounter the compile error corresponding to a basic import statement import { BarSeries } from "react-financial-charts" in one of my files:
Module not found: Error: Can't resolve 'react-financial-charts' in 'C:\Users\user\projects\myproject\src\App'
So basically, the simple import statement which used to work (when I was doing npm install react-financial-charts), is now no longer working when I install the dependency from a local folder instead.
EDIT: I also tried these things that an answer below suggested, but I'm getting the exact same error message:
npm link ../react-financial charts
npm install ../react-financial charts
npm install --save ../react-financial charts
EDIT 2: This ended up working, thanks to the suggested answer below. The trick was I needed to npm update and npm install inside the dependency before linking.
cd react-financial-charts
npm link
cd ../myproject
npm link react-financial-charts
Method 1: Using npm-link
Go to C:\Users\user\projects\react-financial-charts in terminal:
npm link
Now, go to your project C:\Users\user\projects\myproject:
npm link react-financial-charts
Now, any changes to C:\Users\user\projects\react-financial-charts will be reflected in C:\Users\user\projects\myproject. Note that the link should be to the package name, not the directory name for that package.
Method 2: Saving local repo as npm-install
npm install --save ../path/to/mymodule

Need help on a react.js error that I keep on getting

Every time I try running npm start on a new project I keep on getting this error. Does anyone know or have any idea how to fix this??
There might be a problem with the project dependency tree. It is
likely not a bug in Create React App, but something you need to fix
locally.
The react-scripts package provided by Create React App requires a
dependency:
"babel-jest": "^26.6.0"
Don't try to install it manually: your package manager does it
automatically. However, a different version of babel-jest was detected
higher up in the tree:
D:\node_modules\babel-jest (version: 24.9.0)
Manually installing incompatible versions is known to cause
hard-to-debug issues.
If you would prefer to ignore this check, add
SKIP_PREFLIGHT_CHECK=true to an .env file in your project. That will
permanently disable this message but you might encounter other issues.
To fix the dependency tree, try following the steps below in the exact
order:
Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder.
Delete node_modules in your project folder.
Remove "babel-jest" from dependencies and/or devDependencies in the package.json file in your project folder.
Run npm install or yarn, depending on the package manager you use.
In most cases, this should be enough to fix the problem. If this has
not helped, there are a few other things you can try:
If you used npm, install yarn (http://yarnpkg.com/) and repeat the above steps with it instead.
This may help because npm has known issues with package hoisting which may get resolved in future versions.
Check if D:\node_modules\babel-jest is outside your project directory.
For example, you might have accidentally installed something in your home folder.
Try running npm ls babel-jest in your project folder.
This will tell you which other package (apart from the expected react-scripts) installed babel-jest.
If nothing else helps, add SKIP_PREFLIGHT_CHECK=true to an .env file
in your project. That would permanently disable this preflight check
in case you want to proceed anyway.
P.S. We know this message is long but please read the steps above :-)
We hope you find them helpful!
npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR!
react-portfolio#0.1.0 start: react-scripts start npm ERR! Exit
status 1 npm ERR! npm ERR! Failed at the react-portfolio#0.1.0 start
script. npm ERR! This is probably not a problem with npm. There is
likely additional logging output above.
npm ERR! A complete log of this run can be found in: npm ERR!
C:\Users\smaso\AppData\Roaming\npm-cache_logs\2021-01-26T22_50_48_484Z-debug.log
I also face this problem. Simple solution of this problem is:
1)create .env file.
2) add SKIP_PREFLIGHT_CHECK=true in the file.
3) npm start
If this fails to work, create a .env file in the root directory of your project and add the following line
SKIP_PREFLIGHT_CHECK=true
just go to your project's root directory and delete node_module folder and npm start your project.
Delete and redownload node modules and run application again
To fix the dependency tree, try following the steps below in the exact order:
Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder.
Delete node_modules in your project folder.
Remove "babel-jest" from dependencies and/or devDependencies in the package.json file in your project folder.
Run npm install or yarn, depending on the package manager you use.
In most cases, this should be enough to fix the problem.
If this has not helped, there are a few other things you can try:
If you used npm, install yarn (http://yarnpkg.com/) and repeat the above steps with it instead.
This may help because npm has known issues with package hoisting which may get resolved in future versions.
Check if ./babel-jest is outside your project directory.
For example, you might have accidentally installed something in your home folder.
Try running npm ls babel-jest in your project folder.
This will tell you which other package (apart from the expected react-scripts) installed babel-jest.
Seems like you created the react project using create-react-app and installed jest using the following command.
yarn add --dev jest babel-jest #babel/preset-env #babel/preset-react react-test-renderer
But in the documentation it says just to run the following command if you are using create-react-app
yarn add --dev react-test-renderer
[See the documentation][1]https://jestjs.io/docs/tutorial-react
This worked for me.
I used the following command to uninstall jest npm uninstall jest in the root project folder (not the client) and then used the react scripts start command npm start and it worked
removing jest.config.js and uninstall ts-jest solved my problem

npm install --production --prefix giving an error

I went to an issue while trying to create some build steps for Node project.
Issue:
npm install --production --prefix ./.build - Gives me an error
I tried changing the name in the package.json but I still receive the same error:
The current working drectory is important to npm.
Are you sure you're in your app folder?
Please type pwd command if you're unsure...
That error is usually produced when running npm command from a wrong folder...
The problem is, that you have the project you are working on at the moment as dependency in your project - check the package.json file. Try changing the name of the project in package.json.

npm installation in command prompt

After setting new windows in my laptop,i am trying to install npm in command prompt.But i am facing an error which picture is given in below.Would anybody help me out?
If you don't specify a package to install (like npm install -g nodemon) npm will try to install all packages from the current package.json file. If there is non, npm will throw this error.
Npm is already installed. That is why the error message is not Command not found.
The specific command you issued npm install -g attempts to use npm to install the package in the current directory globally.
Leaving the point that installing packages globally is a bad idea aside, this is failing because you are running the command in a directory that does not contain a package. It is your home directory, not one containing a package.json file.
If you are trying to install npm(node package manager) do it by downloading it from here: https://www.npmjs.com/get-npm, then you are good to go.
The command you are actually giving is to install a package using npm(check https://docs.npmjs.com/cli/install).
Thats why the error shows could not install from "" as you have not specified any package to install.

npm WARN enoent ENOENT: no such file or directory, open 'C:\Users\Nuwanst\package.json'

I just want to install socket.io to my project which is located on 3.chat folder. But when I run following command it shows following Warnings.And its not created a node_modules directory inside my project folder. How to fix this?
C:\Users\Nuwanst\Documents\NodeJS\3.chat>npm install socket.io
C:\Users\Nuwanst
`-- socket.io#2.0.3
npm WARN enoent ENOENT: no such file or directory, open 'C:\Users\Nuwanst\package.json'
npm WARN Nuwanst No description
npm WARN Nuwanst No repository field.
npm WARN Nuwanst No README data
npm WARN Nuwanst No license field.
If you already have package-lock.json file just delete it and try again.
Have you created a package.json file? Maybe run this command first again.
C:\Users\Nuwanst\Documents\NodeJS\3.chat>npm init
It creates a package.json file in your folder.
Then run,
C:\Users\Nuwanst\Documents\NodeJS\3.chat>npm install socket.io --save
The --save ensures your module is saved as a dependency in your package.json file.
Let me know if this works.
Make sure you are on the right directory where you have package.json
You need to make sure that the package.json file exist in the app directory. Run this command where package.json file exists.
For more explanation, I run npm start in c:\selfPractice, but my package.json is in c:\selfPractice\frontend. When I switch to c:\selfPractice, it works.
NOTE: if you are experiencing this issue in your CI pipeline, it is usually because npm runs npm ci instead of npm install. npm ci requires an accurate package-lock.json.
To fix this, whenever you are modifying packages in package.json (e.g. moving packages from devDependencies to Dependencies like I was doing) you should regenerate package-lock.json in your repository by running these commands locally, and then push the changes upstream:
rm -rf node_modules
npm install
git commit package-lock.json
git push
If your folder already have package.json
Then,
Copy the path of package.json
Open terminal
Write:
cd your_path_to_package.json
Press ENTER
Then Write:
npm install
This worked for me
finally, I got a solution if you are getting:-
**npm WARN tar ENOENT: no such file or directory,.......**
then it is no issue of npm or its version it is os permission issue to resolve this you need to use below command:-
sudo chown -R $USER:$USER *
additional
sudo chmod -R 777 *
then run:-
sudo npm i
If you're trying to npm install on a folder that's being rsync'd from somewhere else, remember to add this to your rsync --exclude
yourpath/node_modules
Otherwise, NPM will try to add node_modules and rsync will remove it immediately, causing many npm WARN enoent ENOENT: no such file or directory, open errors.
Delete package.json and package-lock.json file
Then type npm init
after that type npm install socket.io --save
finally type npm install
It works for me
update version in package.json is working for me
I just experienced this error but on looking for the answer online here on stackoverflow I found the answer in the process so I decided to share it also , If this error occurs on a react project you are working on and when you run npm start make sure to change directory into the directory that has react installed in it and it will start working
if your node_modules got installed in say /home/UserName/ like in my case,
your package-lock.json file will also be there. just delete this file, go back to your app folder and run npm init and then npm install <pkgname> (e.g express) and a new node_modules folder will be created for your.
I had this in a new project on Windows. npm install had created a node_modules folder for me, but it had somehow created the folder without giving me full control over it. I gave myself full control over node_modules and node_modules\.staging and it worked after that.
Seems you have installed express in root directory.Copy path of package.json and delete package json file and node_modules folder.
I had the same problem, I resolved by removing all insignificant lines in packages.json e only left "name", "version", "description", "devDependencies", "dependencies", "resolutions". and the error was gone.
the file path you ran is wrong. So if you are working on windows, go to the correct file location with cd and rerun from there.

Categories