53

I am trying to learn React and I am using a private repo to start with it.

I run yarn start in the directory of the repo but I get the error message:

yarn run v1.13.0
error Command "start" not found.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

I have both node and yarn installed.

For node:

v10.15.0
node is /usr/local/bin/node

For yarn:

1.13.0
yarn is /usr/local/bin/yarn

I tried to reinstall both node and yarn but I get the same error message. moreover I tried to remove the yarn chance via yarn cache clean but nothing seems to work.

The package.json contains the following:

{
  "name": "02-Manipulating-Strings",
  "version": "1.0.0",
  "author": "ssaunier",
  "license": "UNLICENSED",
  "private": true,
  "devDependencies": {
    "eslint": "^4.7.2",
    "eslint-config-airbnb-base": "^12.0.0",
    "eslint-plugin-import": "^2.7.0",
    "jest": "^21.1.0"
  },
  "scripts": {
    "test": "(eslint lib || true) && jest"
  }
}

The directory is organised in the following way:

project directory

tk421
  • 5,775
  • 6
  • 23
  • 34
Magofoco
  • 5,098
  • 6
  • 35
  • 77

30 Answers30

30

There is no start command inside the scripts of the package.json file.

"scripts": {
  "start": "some command to be run", // you need to add this line
  "test": "(eslint lib || true) && jest"
}

Maybe you want to run the test command instead - npm test / yarn test?

Tsvetan Ganev
  • 8,246
  • 4
  • 26
  • 43
  • That is what I was thinking too but I have 2 remarks. 1) I opened the solution file of the private repo and the soultion's `package.json` matches mine (plus, yesterday eberything was working) 2) How can I run the JS files in the folder `lib` if i do not run `yarn start`? I tried with `npm run` but I get: `Lifecycle scripts included in 02-Manipulating-Strings: test (eslint lib || true) && jest` – Magofoco Jan 27 '19 at 22:08
  • If I try to run: `node lib/01_dash_insertion.js` nothing happen. So I tried to install `npm install --save-dev webpack`but still I cannot run any js file. – Magofoco Jan 27 '19 at 22:33
  • "start": "webpack-dev-server --mode development" – Fábio BC Souza May 19 '19 at 14:49
8

Just run

yarn add react-scripts
rohittheozzy
  • 309
  • 3
  • 4
5

Solved it thanks to the insight of the user: Tsvetan Ganev.

I was trying to run a command that it is not in my scripts. Specifically, yarn start is not in the scripts part of the file package.json. To solve the issue I added the following line in scripts

"start": "webpack-dev-server --mode development",
Magofoco
  • 5,098
  • 6
  • 35
  • 77
4

You can also try to run first npm install and then npm run or first yarn and then yarn start

Magofoco
  • 5,098
  • 6
  • 35
  • 77
  • I tried with yarn and yarn start, I am still getting the following error. yarn run v1.22.10 warning package.json: No license field error Command "start" not found. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. – jyotisankar May 17 '21 at 09:15
  • Try adding: "start": "react-scripts start" in your "scripts" inside package.json – Magofoco May 17 '21 at 17:58
4

I got the same error message "start" command not found. My issue got resolved by following the below mentioned steps.

-open the folder in which you want to create the app using terminal then type these commands:

  1. npm uninstall -g create-react-app
  2. npx create-react-app FolderName

(This will automatically install the latest create-react-app version)

-Then run the command yarn start and it will work.

Priyanka
  • 41
  • 2
4

I had this problem. I figured the best way is this.

  1. npm i -g create-react-app
  2. create-react-app my-react-app //or whatever you want your project to be
  3. cd my-react-app
  4. yarn start
Med Sep
  • 346
  • 1
  • 6
3

I had the same issue start command not found. I followed below instruction to recreate react app

. Go to your parent folder in cmd
. Type yarn add create-react-app
. And yarn create-react-app FolderName

After installing yarn start will work.

After Installing react folder

Ankur
  • 151
  • 7
3

Well, I was getting this error cause I was dumb Not going inside the main project folder.so it actually not able to find .json file too

1

Adding this to package.json worked for me

  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web",
    "eject": "expo eject"
  },"devDependencies": {
    "babel-preset-expo": "^7.0.0"
  },
1

If you are using create-react-app and encountered this error, chances are you did not install create-react-app successfully.

Try removing globally installed create-create-app as explained below.

Template not provided using create-react-app

ohkts11
  • 2,581
  • 2
  • 21
  • 17
1

check your package.json that has "start" scripts. if you just have dependency list, make sure you have the following on the package.jons

"devDependencies": {
    "@theia/cli": "next"
  },
  "scripts": {
    "prepare": "yarn run clean && yarn build && yarn run download:plugins",
    "clean": "theia clean",
    "build": "theia build --mode development",
    "start": "theia start --plugins=local-dir:plugins",
    "download:plugins": "theia download:plugins"
  },
  "theiaPluginsDir": "plugins",
  "theiaPlugins": {
    "vscode-builtin-css": "https://github.com/theia-ide/vscode-builtin-extensions/releases/download/v1.39.1-prel/css-1.39.1-prel.vsix",
    "vscode-builtin-html": "https://github.com/theia-ide/vscode-builtin-extensions/releases/download/v1.39.1-prel/html-1.39.1-prel.vsix",
    "vscode-builtin-javascript": "https://github.com/theia-ide/vscode-builtin-extensions/releases/download/v1.39.1-prel/javascript-1.39.1-prel.vsix",
    "vscode-builtin-json": "https://github.com/theia-ide/vscode-builtin-extensions/releases/download/v1.39.1-prel/json-1.39.1-prel.vsix",
    "vscode-builtin-markdown": "https://github.com/theia-ide/vscode-builtin-extensions/releases/download/v1.39.1-prel/markdown-1.39.1-prel.vsix",
    "vscode-builtin-npm": "https://github.com/theia-ide/vscode-builtin-extensions/releases/download/v1.39.1-prel/npm-1.39.1-prel.vsix",
    "vscode-builtin-scss": "https://github.com/theia-ide/vscode-builtin-extensions/releases/download/v1.39.1-prel/scss-1.39.1-prel.vsix",
    "vscode-builtin-typescript": "https://github.com/theia-ide/vscode-builtin-extensions/releases/download/v1.39.1-prel/typescript-1.39.1-prel.vsix",
    "vscode-builtin-typescript-language-features": "https://github.com/theia-ide/vscode-builtin-extensions/releases/download/v1.39.1-prel/typescript-language-features-1.39.1-prel.vsix"
  }
}

otherwise run this on the folder where package.json is

error Command "start" not found.

yarn run theia start /home --hostname 0.0.0.0 --port 8080

theia should start on port 8080 minimally.

Arun Panneerselvam
  • 2,263
  • 1
  • 17
  • 24
1

Nov 2020

This might happen when you clone a git repo created with an older version of create-react-app or event with another setup. First install react-scripts as

yarn add react-scripts

Or

npm install react-scripts

Then if having problem with react-scripts, refer to this SO thread.

DevLoverUmar
  • 11,809
  • 11
  • 68
  • 98
1

If you get error Command "start" not found. after creating new project using create-react-app you most probably would have created the app using npm.

To do it correctly delete the directory of the project and recreate the project using yarn with the following command

 yarn create react-app my-app

After that yarn start works perfectly fine.

Toshal Agrawal
  • 173
  • 2
  • 7
1

i got the same issue. it cusses you have installed packages in wrong directory.

in cmd terminal:-(D:\PROJECT)=> my cmd file path shows

D:\PROJECTS\npx create-react-app app-react

(when you enter this command it will create new file named app-react . then you have to go into the app-react file . use this command to go to the that file "cd app-react" then enter. you will see cmd path )

D:\PROJECTS\cd app-react
D:\PROJECTS\app-react\

then install other yarn packges

D:\PROJECTS\app-react\yarn add @chakra-ui/react @emotion/react@^11 @emotion/styled@^11 framer-motion@^4

D:\PROJECTS\app-react\yarn add react-icons

D:\PROJECTS\app-react\yarn add react-router-dom

then yarn start

D:\PROJECTS\app-react\yarn start

if it is won't open check yarn package installed using this command

D:\PROJECTS\app-react\yarn -version
1.22.10

for install yarn

npm install --global yarn
gihan22603
  • 11
  • 3
1

just run following commands:

  1. npm uninstall -g create-react-app
  2. npx create-react-app FolderName
0

I had a similar problem while I have "start" script in my package.json. Eventually, I figured out that I had not saved the package.json, so I got this error. Obviously, after saving the package.json the problem was resolved.

Abdollah
  • 4,579
  • 3
  • 29
  • 49
0

This issue happens when file "package.json" will gets deleted or changed. Please check your "package.json" file.

0

It may sound silly, but I was having this same problem and all I did was close the program (vscode), and reopen it. I made sure it was inside the correct project folder (web) and did the process again. It worked. In my case it was just a lack of attention.

I hope your problem is as simple as mine.

Hug!

0

i solve the problem whit this: Since create-react-app 3.3.0 it's not longer recommended to use a global installation of CRA.

However, after following the recommended way, uninstalling CRA globally and using npm,I ran into the following problem for my new React project:

A template was not provided. This is likely because you're using an outdated version of create-react-app.

It seems like CRA wasn't properly uninstalled. I had to do the following:

After uninstalling it with npm uninstall -g create-react-app, check whether you still have it "installed" with which create-react-app on your command line. If it returns something (e.g. /usr/local/bin/create-react-app), then do a rm -rf /usr/local/bin/create-react-app to delete manually.

Afterward, I was able to use npx create-react-app my-app with the latest version of CRA where I would have the default template for the src/ folder

0

Firstly, you can try

npm install

then

You can also try to run first npm install and then npm run or first yarn and then yarn start

0

I have solved my issues with the following command. Try this command, hope you will get rid of the problems.

npm run start
Shiplu
  • 460
  • 6
  • 13
0

I also face this error but in my case I think, I have done all the above steps but the error still remaining the last thing I did in my main node_module/.bin/ folder I saw there are two dependencies one is create-react-app it fine but another one is creat-app-react so I deleted this dependency and also remove from my package.json file.

So now yarn start is working perfectly.

Leo
  • 1,990
  • 1
  • 13
  • 20
Tariq Nawaz
  • 41
  • 1
  • 2
  • This is not related to this case. The OP had a problem with running a command that did not exist in the package json because it was not intended to. – Markiian Benovskyi Aug 25 '21 at 10:14
0

just run command

corepack disable

if you ran the following command before

corepack enable
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Mar 27 '22 at 11:43
0

I was outside the project. So I type cd myProject and than yarn run

Java bee
  • 2,522
  • 1
  • 12
  • 25
0
{
        test: /\.scss$/,
        include: [/vue-components|views/],
        use: [
          'vue-style-loader',
          'css-loader',
          'sass-loader',
        ],
},

put this in webpack.config.js in module object.

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Apr 16 '22 at 14:46
0

one of the reasons behind this is watch if you are in the right directory type cd your_file_name then type npm run dev

0

I had the same issue. Just run

npm install --global yarn
  • this error happens when you're running `yarn start` in a wrong directory instead of the root directory where package.json is. if they didn't have yarn installed then they would've gotten a different error like yarn is not found. – zahra shahrouzi May 15 '22 at 19:02
0
 "scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "jest",
"eject": "react-scripts eject"  }, 

I found that when I added this into the scripts section package.json dependency; it worked! This way, you'll get the https://localhost:3000 instead of using the 8080 port.

enter image description here

Jamil Matheny
  • 180
  • 1
  • 7
0

I had this problem and just solved it! Super easy, I hope it helps you:

The problem: "node_modules" was duplicated. You may have accidentally downloaded a duplicated "node_modules" folder when calling yar originally.

Go to "User/#yourname/node_modules" and delete the folder.

-1

just start the app via debug option enter image description here

asar
  • 1
  • https://meta.stackoverflow.com/a/285557/7733418 – Yunnosch Feb 20 '23 at 11:03
  • Please make the differce to the exsting answer more obvious. You seem to just say thanks for https://stackoverflow.com/a/73004724/7733418 – Yunnosch Feb 20 '23 at 11:04
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Feb 24 '23 at 01:27