Unable to do `npm start` - javascript

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"

Related

Dependencies ignored and deleted from package-lock.json after npm install

I'm trying to run an JS Chrome extension from a cloned repository. The problem occurs after I run npm install where some of the dependencies in the package-lock.json file gets deleted and essentially ignored. This causes the project to miss many of the modules necessary for it to run.
I've tried using npm ci but it still has the same problem. I've also tried using yarn and yarn check but to no avail. What is the problem here? Why doesn't npm install all the dependencies in package-lock.json file without having to delete some of them?

cannot find babel-runtime library

When I am running yarn test:watch, I am getting this error.
Cannot find module 'babel-runtime/helpers/toConsumableArray' from 'node_modules/pandas-js/dist/core/series.js'
Require stack:
node_modules/pandas-js/dist/core/series.js
node_modules/pandas-js/dist/core/index.js
node_modules/pandas-js/dist/index.js
at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:306:11)
at Object.<anonymous> (node_modules/pandas-js/dist/core/series.js:8:27)
I tired
npm install --save-exact #babel/runtime#7.0.0-beta.55
and then deleted node-modules folder and package-lock.json file and tried npm install again
That did not solve the issue too. Can anyone help me in this please.
This is the version of pandas-js library
"pandas-js": "^0.2.4",
in my package.json
it works after I installed babel-cli, a lot of people have said this works for them #babel/runtime#7.0.0-beta.55, but for me babel-cli helped.
you can try simply deleting the node-modules folder from your project directory, and run npm install command can also use yarn to re-install the dependencies in your project

npm wont start a react app, requires a dependency: "webpack-dev-server": "3.1.14"

I am trying to create a new react-app and start it, I have created react apps before with no errors but this time when i npm start i get this error
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:
"webpack-dev-server": "3.1.14"
Don't try to install it manually: your package manager does it
automatically.
However, a different version of webpack-dev-server was detected higher up
in the tree:
C:\Users\ashraf\node_modules\webpack-dev-server (version: 3.1.9)
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:
1. Delete package-lock.json (not package.json!) and/or yarn.lock in your
project folder.
2. Delete node_modules in your project folder.
3. Remove "webpack-dev-server" from dependencies and/or devDependencies in
the package.json file in your project folder.
4. 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:
5. 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.
6. Check if C:\Users\ashraf\node_modules\webpack-dev-server is outside
your project directory.
For example, you might have accidentally installed something in your home
folder.
7. Try running npm ls webpack-dev-server in your project folder.
This will tell you which other package (apart from the expected react-
scripts) installed webpack-dev-server.
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! learnreact#0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the learnreact#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\ashraf\AppData\Roaming\npm-cache\_logs\2019-02-
04T20_36_39_924Z-debug.log
PS C:\Users\ashraf\Desktop\Files\LearnReact\learnreact>
i have tried all the steps in detail in the error log but its still not working, any thoughts on what is causing this error? Thanks in advance
It seems like you want to depend on webpack-dev-server inside your local project.
Perhaps you need to run npm install in your project, instead of your ~ home directory?
from your output, notice these lines.
However, a different version of webpack-dev-server was detected higher up
in the tree:
C:\Users\ashraf\node_modules\webpack-dev-server (version: 3.1.9)
...
6. Check if C:\Users\ashraf\node_modules\webpack-dev-server is outside
your project directory.
For example, you might have accidentally installed something in your home
folder.
so I would
cd ./my-project
npm i
Did you install webpack-dev-server on its own? It seems it has been installed either by you or by another project install. Webpack is for your local development environment so the other install is close enough to your project to interfere with the copy that react is trying to install in your project folder. Steps 1-4 in your error message should resolve your issue. If you have done that and its still not working, did you get different error messages with your next attempt to install your react package?
I have faced the same issue and this method worked for me.
Do follow the steps:
Start terminal from the desktop and write this command:
npm uninstall webpack-dev-server
This will uninstall webpack-dev-server package globally from you node modules.
Go back to you the terminal of your project and install webpack-dev-server package:
npm install webpack-dev-server#version
Note: The version part (above) should equal the versions asked for in the error message.
npm install webpack-dev-server
Now start npm:
npm start
This error mostly occurs when you have created your project using the
npx create-react-app command instead of the npm create-react-app command.

npm start and install are not working

I tried to run npm install and npm start but both does not work. I reinstalled the nodejs but still the same. How to resolve it?
If you're trying to install the dependencies of an existing project (which the context implies), you need to run the command npm install in the directory where the package.json file of the project is.
If you've created a new and empty project folder, you need to first run npm init to create a package.json file which is used to manage the dependencies of your project.
Are you sure you're in the head directory? For example, if your project is in:
$ Documents/Projects/JS-Projects/Work/Client-Management-App/
Then that's the folder you need to be in: the Client-Management-App/ directory, because that's where the package.json file and the /node_modules/ folder will be created.
Also, have you run npm init? That might be another reason why.

"Could not find a required file" on `yarn start`

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!

Categories

Resources