[英]Error: yarn start - error Command "start" not found
I am trying to learn React and I am using a private repo to start with it.我正在尝试学习 React,并且我正在使用私人回购开始。
I run yarn start
in the directory of the repo but I get the error message:我在 repo 的目录中运行
yarn start
但收到错误消息:
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.此外,我尝试通过
yarn cache clean
删除纱线机会,但似乎没有任何效果。
The package.json
contains the following: package.json
包含以下内容:
{
"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:该目录按以下方式组织:
There is no start
command inside the scripts of the package.json
file. package.json
文件的脚本中没有start
命令。
"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
?也许你想运行
test
命令 - npm test
/ yarn test
?
Solved it thanks to the insight of the user: Tsvetan Ganev.感谢用户的洞察力解决了这个问题: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
.具体来说,
yarn start
不在package.json
文件的scripts
部分。 To solve the issue I added the following line in scripts
为了解决这个问题,我在
scripts
添加了以下行
"start": "webpack-dev-server --mode development",
赶紧跑
yarn add react-scripts
您也可以尝试先运行npm install
然后npm run
或先npm run
yarn
然后npm run
yarn start
I had this problem.我有这个问题。 I figured the best way is this.
我想最好的方法是这个。
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: - 使用终端打开要在其中创建应用程序的文件夹,然后键入以下命令:
(This will automatically install the latest create-react-app version) (这将自动安装最新的 create-react-app 版本)
-Then run the command yarn start and it will work. - 然后运行命令yarn start ,它会工作。
Adding this to package.json worked for me将此添加到 package.json 对我有用
"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"
},
If you are using create-react-app and encountered this error, chances are you did not install create-react-app successfully.如果您正在使用 create-react-app 并遇到此错误,则可能是您没有成功安装 create-react-app。
Try removing globally installed create-create-app as explained below.尝试删除全局安装的 create-create-app,如下所述。
Template not provided using create-react-app 未使用 create-react-app 提供模板
check your package.json that has "start" scripts.检查具有“启动”脚本的 package.json。 if you just have dependency list, make sure you have the following on the package.jons
如果您只有依赖项列表,请确保您在 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否则在 package.json 所在的文件夹上运行它
error Command "start" not found.错误命令“开始”未找到。
yarn run theia start /home --hostname 0.0.0.0 --port 8080
theia should start on port 8080 minimally. theia 应该至少在端口 8080 上启动。
If you get error Command "start" not found.
如果您收到
error Command "start" not found.
after creating new project using create-react-app you most probably would have created the app using npm
.使用 create-react-app 创建新项目后,您很可能会使用
npm
创建该应用npm
。
To do it correctly delete the directory of the project and recreate the project using yarn with the following command要正确执行此操作,请删除项目目录并使用以下命令使用 yarn 重新创建项目
yarn create react-app my-app
After that yarn start works perfectly fine.在那之后纱线开始工作得很好。
i got the same issue.我遇到了同样的问题。 it cusses you have installed packages in wrong directory.
它诅咒你在错误的目录中安装了软件包。
in cmd terminal:-(D:\\PROJECT)=> my cmd file path shows在 cmd 终端中:-(D:\\PROJECT)=> 我的 cmd 文件路径显示
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 ) (当您输入此命令时,它将创建名为 app-react 的新文件。然后您必须进入 app-react 文件。使用此命令转到该文件“cd app-react”然后输入。您将看到 cmd小路 )
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
just run following commands:只需运行以下命令:
I had a similar problem while I have "start"
script in my package.json
.当我的
package.json
有"start"
脚本时,我遇到了类似的问题。 Eventually, I figured out that I had not saved the package.json
, so I got this error.最终,我发现我没有保存
package.json
,所以我收到了这个错误。 Obviously, after saving the package.json
the problem was resolved.显然,保存
package.json
后问题就解决了。
This issue happens when file "package.json" will gets deleted or changed.当文件“package.json”被删除或更改时会发生此问题。 Please check your "package.json" file.
请检查您的“package.json”文件。
It may sound silly, but I was having this same problem and all I did was close the program (vscode), and reopen it.这听起来可能很愚蠢,但我遇到了同样的问题,我所做的只是关闭程序(vscode),然后重新打开它。 I made sure it was inside the correct project folder (web) and did the process again.
我确保它在正确的项目文件夹 (web) 中并再次执行该过程。 It worked.
有效。 In my case it was just a lack of attention.
就我而言,这只是缺乏关注。
I hope your problem is as simple as mine.我希望你的问题和我的一样简单。
Hug!拥抱!
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.我解决了这个问题:从 create-react-app 3.3.0 开始,不再推荐使用 CRA 的全局安装。
However, after following the recommended way, uninstalling CRA globally and using npm,I ran into the following problem for my new React project:但是,按照推荐的方式,全局卸载 CRA 并使用 npm 后,我的新 React 项目遇到了以下问题:
A template was not provided.未提供模板。 This is likely because you're using an outdated version of create-react-app.
这可能是因为您使用的是过时版本的 create-react-app。
It seems like CRA wasn't properly uninstalled.好像没有正确卸载 CRA。 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.使用 npm uninstall -g create-react-app 卸载它后,检查您是否仍然在命令行上使用 which create-react-app “安装”了它。 If it returns something (eg /usr/local/bin/create-react-app), then do a rm -rf /usr/local/bin/create-react-app to delete manually.
如果它返回一些东西(例如/usr/local/bin/create-react-app),然后执行 rm -rf /usr/local/bin/create-react-app 手动删除。
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之后,我能够将 npx create-react-app my-app 与最新版本的 CRA 一起使用,其中我将拥有 src/ 文件夹的默认模板
Nov 2020 2020 年 11 月
This might happen when you clone a git repo created with an older version of create-react-app or event with another setup.当您克隆使用旧版本的 create-react-app 或具有其他设置的事件创建的 git 存储库时,可能会发生这种情况。 First install react-scripts as
首先将反应脚本安装为
yarn add react-scripts
纱线添加反应脚本
Or或者
npm install react-scripts
npm 安装反应脚本
Then if having problem with react-scripts, refer to this SO thread .然后,如果 react-scripts 有问题,请参阅此 SO thread 。
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您也可以尝试先运行 npm install 然后运行 npm run 或先运行 yarn 然后运行 yarn start
I have solved my issues with the following command.我已经使用以下命令解决了我的问题。 Try this command, hope you will get rid of the problems.
试试这个命令,希望你能摆脱这些问题。
npm run start
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.我也面临这个错误,但在我的情况下,我认为,我已经完成了上述所有步骤,但错误仍然是我在主
node_module/.bin/
文件夹中做的最后一件事我看到有两个依赖项,一个是create-react-app
它很好,但另一个是creat-app-react
所以我删除了这个依赖项,并从我的 package.json 文件中删除。
So now yarn start is working perfectly.所以现在纱线开始工作完美。
好吧,我收到了这个错误,因为我很笨 没有进入主项目文件夹。所以它实际上也无法找到 .json 文件😁
just run command只需运行命令
corepack disable
if you ran the following command before如果您之前运行过以下命令
corepack enable
I was outside the project.我在项目之外。 So I type
cd myProject
and than yarn run
所以我输入
cd myProject
而不是yarn run
{
test: /\.scss$/,
include: [/vue-components|views/],
use: [
'vue-style-loader',
'css-loader',
'sass-loader',
],
},
put this in webpack.config.js in module object.把它放在模块对象的 webpack.config.js 中。
这背后的原因之一是注意如果你在正确的目录中,输入 cd your_file_name 然后输入 npm run dev
I had the same issue.我遇到过同样的问题。 Just run
赶紧跑
npm install --global yarn
"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;我发现当我将它添加到脚本部分 package.json 依赖项时; it worked!
有效! This way, you'll get the https://localhost:3000 instead of using the 8080 port.
这样,您将获得 https://localhost:3000 而不是使用 8080 端口。
I had this problem and just solved it!我遇到了这个问题,刚刚解决了! Super easy, I hope it helps you:
超级简单,希望对你有帮助:
The problem: "node_modules" was duplicated.问题:“node_modules”被重复了。 You may have accidentally downloaded a duplicated "node_modules" folder when calling yar originally.
最初调用 yar 时,您可能不小心下载了重复的“node_modules”文件夹。
Go to "User/#yourname/node_modules" and delete the folder.转到“用户/#yourname/node_modules”并删除该文件夹。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.