Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Couldn't find a package.json ... when install react-scripts #1058

Closed
schovi opened this issue Oct 14, 2016 · 23 comments
Closed

Couldn't find a package.json ... when install react-scripts #1058

schovi opened this issue Oct 14, 2016 · 23 comments
Labels

Comments

@schovi
Copy link

schovi commented Oct 14, 2016

  1. Having empty new directory
  2. Init new package.json (tried with yarn and npm)
  3. add react-scripts package (can be added manually into package.json, but it does not matter)
  4. Getting error: error Couldn't find a package.json (or bower.json) file in /Users/schovi/tmp/xxx/node_modules/react-scripts/node_modules/autoprefixer
15:51 $ mkdir ~/tmp/xxx && cd ~/tmp/xxx
~/tmp/xxx
15:51 $ yarn init
yarn init v0.15.1
questions ...
✨  Done in 2.89s.
15:51 $ yarn add react-scripts
yarn add v0.15.1
info No lockfile found.
[1/4] 🔍  Resolving packages...
warning react-scripts > jest > jest-cli > istanbul-api > fileset > minimatch@2.0.10: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
error Couldn't find a package.json (or bower.json) file in /Users/schovi/tmp/xxx/node_modules/react-scripts/node_modules/autoprefixer
    at /usr/local/Cellar/yarn/0.15.1/libexec/lib/node_modules/yarn/lib/config.js:355:13
    at next (native)
    at step (/usr/local/Cellar/yarn/0.15.1/libexec/lib/node_modules/yarn/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)
    at /usr/local/Cellar/yarn/0.15.1/libexec/lib/node_modules/yarn/node_modules/babel-runtime/helpers/asyncToGenerator.js:28:20
info Visit http://yarnpkg.com/en/docs/cli/add for documentation about this command.

System:
OSx Sierra
Node 6.8.0
Yarn 0.15.1 (installed via homebrew)

PS: when installing with npm, everything is fine.

@sebmck sebmck changed the title Bug: Couldn't find a package.json ... when install react-scripts Couldn't find a package.json ... when install react-scripts Oct 14, 2016
@trbngr
Copy link

trbngr commented Oct 14, 2016

Same issue here.

@busches
Copy link
Contributor

busches commented Oct 19, 2016

Please retest with yarn 0.16.+, I'm unable to reproduce the error now.

@schovi
Copy link
Author

schovi commented Oct 19, 2016

@busches Same error

[3/4] 🔗  Linking dependencies...
error Couldn't find a package.json (or bower.json) file in /Users/schovi/tmp/xx/node_modules/react-scripts/node_modules/autoprefixer

version is really 0.16.0

@torifat
Copy link
Member

torifat commented Oct 20, 2016

Weird! works for me. I'm using the same version 0.16.0. Node v6.9.1 & macOS 10.12.

screenshot 2016-10-20 16 21 49

@schovi
Copy link
Author

schovi commented Oct 20, 2016

Solved! yarn cache clean helped. Not sure how broken version get there.

@joe4mg
Copy link

joe4mg commented Jun 26, 2017

This might help someone else who stumbles across this page - I had this error when my directory/package.json didn't have the right file permissions

@jalavosus
Copy link

@joe4mg, what permissions does the package.json need?

@philpoore
Copy link

philpoore commented Mar 26, 2018

I was also finding this issue.
@schovi yarn cache clean didn't fix the problem for me.

Was running version v0.27.5, fairly out of date.
Upgraded yarn to latest version v1.5.1 via brew with:

brew upgrade yarn

And that fixed it.

package.json resolution works in sub-folders again.
😃😃😃😃😃😃😃😃

@MoonMoonLight
Copy link

yarn cache clean didn't solve my problem (couldn't find package,json file). But running it as administrator (-@windows) did.

@kleviss
Copy link

kleviss commented Jun 2, 2019

My case was that I was not in the right folder when I run yarn. I had another folder inside the folder where I tried to run yarn start. The project files were in the other folder nested.cdto the correct folder and run yarn start - This worked for me.

@lalaphoon
Copy link

In my case, I just went to a wrong directory - the parent directory of my react project.
So just make sure in the directory where you contains your react project.
(Yes, I guessed. My comment will be downvoted.)

@namdh-1522
Copy link

cd your_react_app
then
yarn start

@HugoRamonPereira
Copy link

My case was that I was not in the right folder when I run yarn. I had another folder inside the folder where I tried to run yarn start. The project files were in the other folder nested.cdto the correct folder and run yarn start - This worked for me.

this was the fix, it worked for me, thanks a lot man, really helped me a lot

@mali30
Copy link

mali30 commented Jan 3, 2020

just ran into this issue also. make sure your in the same directory as your package.json.

@magaldistudio
Copy link

Muito bom !!!
eu tbm acionei yarn start no diretorio errado .
obrigado

@AtikRhaman
Copy link

For me, I wan in the wrong folder, cd to the right project and yarn run develop

@abdifatahmohamad
Copy link

cd your_react_app
then
yarn start

Thank you, it did work for me.

@freshmurry
Copy link

yarn add package.json worked for me

@GustavoMori
Copy link

When you create a new project with "yarn create ..." you aren't in the correct folder, so cd (name of project) then yarn start :)

@freshmurry
Copy link

freshmurry commented Aug 4, 2020 via email

@Marcianas1l
Copy link

Meu caso foi que eu não estava na pasta correta quando executo yarn. Eu tinha outra pasta dentro da pasta onde tentei executar yarn start. Os arquivos do projeto estavam na outra pasta aninhada . cdpara a pasta correta e execute yarn start - Isso funcionou para mim.

Obrigada por compartilhar essa informação, resolveu meu problema!

@eddskt
Copy link

eddskt commented Oct 29, 2020

yarn cache clean didn't solve my problem (couldn't find package,json file). But running it as administrator (-@windows) did.

this solved my problem, simple, thks

@anedejour
Copy link

My case was that I was not in the right folder when I run yarn. I had another folder inside the folder where I tried to run yarn start. The project files were in the other folder nested.cdto the correct folder and run yarn start - This worked for me.

tks a lot!

@yarnpkg yarnpkg locked as resolved and limited conversation to collaborators Jun 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests