I set up a create-react-app and I'm trying to run App.js on localhost, but upon doing yarn start I get the following error message:
22:23 $ yarn start
yarn run v1.3.2
$ react-scripts start
Could not find a required file.
Name: index.html
Searched in: /Users/-----/Desktop/---/----/hw/HW-REPO/hw-name/public
error Command failed with exit code 1.
I'd already installed yarn with yarn install, so I'm not sure if there's something wrong with my code or with the file structure.
Here's the file structure:
app-name
-client
--public
---index.html
---manifest.json
--src
---Components
----various folders
---App.js
---App.test.js
---index.js
-database
-model
-gitignore
-package-lock.json
-package.json
-server.js
-yarn.lock
In my case command npm audit fix --force change version of react-scripts in package.json As I created app with --template typescript, older version of react-scripts could not find index.js, but I have index.tsx
I solve this by removing package-lock.json, node-modules folder and remove react-scripts from package.json, then npm i react-scripts
In my case I opened my wrong folder in vs code and was trying to run npm start from their and npm did not find the index.html in that path, so I looked the correct path and reopened the folder and got no issue. Hope this will help some new beginner.
Update: I moved yarn.lock and package.json into the client folder, did yarn install again, and then ran yarn start. Now I'm seeing good ol' error messages in the browser. I'm not 100% sure if shuffling the files around did the trick or if it was doing yarn install again, but at least it's working now.
#Tsardines I was experiencing the same issue, but the 'Could not find a required file' my program was referencing was 'index.js'.
$ yarn start
# yarn run v1.13.0
# warning ..\..\..\..\package.json: No license field
$ react-scripts start
# Could not find a required file.
# Name: index.js`
This was because my index.js file was in the root folder of my project, instead of being
in the 'src' folder.
I moved the file to src folder, ran 'yarn start'.
Presto!
Related
I did an npx create-react-app then I did an npm start to see if it worked, and when I did it, it gave me this error I don't really know why it is giving me this error, but I tried everything that it said, yet it keeps giving the error.
You should remove the node_modules folder inside your home folder, the one at C:\Users\Simone\node_modules. Also, double-check that you don't have a package.json or package-lock.json files in your home folder.
It looks like the error is related to a version conflict for that dependency. You could uninstall your version of Webpack with npm uninstall webpack, add the below dependency to your package.json file, then run npm i to get up-to-date.
"webpack": "4.44.2"
I am using Node version 14.15.5 and npm version 6.14.11. Also, I am working on VS Code.
I have tried to install two packages by these commands:
npm install express
npm install lodash
In the end, I am not getting any of them successfully.
I received this message:
36 packages are looking for funding
run `npm fund` for details.
How to resolve this issue?
enter image description here
The reason is described here:
Before installing a package into the local folder, NPM tries to find the root of your package. To do this it walks from your current directory (C:\Users\JD Mughal\Desktop\Web\Node\test-calculator) up the hierarchy until it finds a package.json file.
Only if no package.json file is found will NPM install the new package in the current directory (respectively in a node_modules\package_name subdirectory).
In your case however NPM finds a package.json file C:\Users\JD Mughal\package.json and installs the new package there.
To resolve the use you must execute npm init in your local directory.
I am trying to follow with pluralsight tutorial and he wrote npm install on the terminal, then a file called npm module is installed on the folder he specified. when I try to install npm this appears to me in the terminal, and the directory which Im trying to install npm on it contains only one document called package-lock.json enter image description here
npm install uses the package.json to install the necessary packages
I can see when you ls, there's no package.json in the directory, just the package-lock which is created where ever you run npm install
Make sure you run the npm install from the same directory the package.json in contained in
the problem is solved, I think that I download the web-dev-starter folder twice by mistake.
After I create my react project with
npx create-react-app
my-app I run
npm start
and get this error as you can see below in the image
node version: 12.16.1
npm version: 6.13.4
enter image description here
I will be grateful if you show me a solution!
and this is my package.js file
https://imgur.com/v8yeKrR
Try removing your node_modules and package-lock.json.
Then reinstall npm i
then start npm start
These kind of problems could be happening when clashing react modules. Delete node_module folder and package-lock.json file. Then run again npm install and npm start.
Use yarn create react-app my-app , cd my-app ,npm start .Now download all the dependencies form npm or yarn. It will work.
When running the terminal commands ng server or ng serve I'm getting this issue:
An unhandled exception occurred: Could not find module "#angular-devkit/build-angular"
Check in your package.json to see if you have this package in your devDependencies section or not
"devDependencies": {
"#angular-devkit/build-angular": "~0.803.18"
}
If exist try to
delete package-lock.json or yarn-lock.json
run
npm cache clean --force
then run
npm i
Install #angular-devkit/build-angular as dev dependency.
npm install --save-dev #angular-devkit/build-angular
or,
yarn add #angular-devkit/build-angular --dev
This error (Unhandled exception for a module) occurs when node_modules folder does not exist inside the project, or when the folder exists, but does not contain all the dependencies downloaded.
$ npm install command will download all the dependencies into the node_modules folder of the proejct.
npm install is automatically triggered in the background by the 'ng new', at the time of creation of the angular project.
The other angular commands like 'ng build' or 'ng serve' commands assume that 'ng new' had completed successfully.
If, for some reason, the npm install failed at the time of creation, or if the node_modules folder got deleted after the project was created, then the other angular commands (ng serve, ng build, ...) will generate this 'Unhandled Exception'.
Manually executing the npm install command inside the project will download the dependencies and fix the issue.
try this
npm install --save-dev #angular-devkit/build-angular
Make sure "#angular-devkit/build-angular": "~0.10.0" is available in devDependencies of package.json before running npm install in your angular root directory.