Error: yarn start - error Command “start” not found
我正在尝试学习React,并且我正在使用一个私有仓库来开始它。
我在回购目录中运行
1 2 3 | yarn run v1.13.0 error Command"start" not found. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. |
我同时安装了结点和Yarn。
对于节点:
1 2 | v10.15.0 node is /usr/local/bin/node |
对于Yarn:
1 2 | 1.13.0 yarn is /usr/local/bin/yarn |
我尝试重新安装node和yarn,但收到相同的错误消息。此外,我尝试通过
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | { "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" } } |
目录的组织方式如下:
1 2 3 4 | "scripts": { "start":"some command to be run", // you need to add this line "test":"(eslint lib || true) && jest" } |
也许您想改为运行
借助用户的洞察力Tsvetan Ganev解决了该问题。
我试图运行一个不在脚本中的命令。具体来说,
为了解决该问题,我在
中添加了以下行
1 | "start":"webpack-dev-server --mode development", |
只要运行
1 | yarn add react-scripts |
我没有找到相同的问题启动命令。
我按照以下说明重新创建react app
1 2 3 | . Go to your parent folder in cmd . Type yarn add create-react-app . And yarn create-react-app FolderName |
安装Yarn后,将开始工作。
您也可以尝试先运行
我遇到了这个问题。我想最好的方法就是这个。
我没有找到相同的错误消息" start "命令。通过执行以下提到的步骤可以解决我的问题。
-使用终端打开您要在其中创建应用程序的文件夹,然后键入以下命令:
(这将自动安装最新的create-react-app版本)
-然后运行命令yarn start,它将起作用。
将其添加到package.json对我有用
1 2 3 4 5 6 7 8 9 | "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" }, |
检查具有" start "脚本的package.json。
如果您只有依赖项列表,请确保在软件包中包含以下内容。jons
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | "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" } } |
否则在package.json为
的文件夹上运行此文件
找不到错误命令" start "。
1 | yarn run theia start /home --hostname 0.0.0.0 --port 8080 |
theia应该至少从8080端口启动。
如果您正在使用create-react-app并遇到此错误,则可能是您未成功安装create-react-app。
尝试按照以下说明删除全局安装的create-create-app。
未使用create-react-app
提供的模板
首先,您可以尝试
1 | npm install |
然后
您也可以尝试先运行npm install,然后再运行npm run或先运行yarn,然后运行yarn start
听起来可能很愚蠢,但是我遇到了同样的问题,我所做的只是关闭程序(vscode),然后重新打开它。我确保它在正确的项目文件夹(web)中,然后再次执行此过程。有效。就我而言,这只是缺乏关注。
我希望你的问题像我的一样简单。
拥抱!
我解决了这个问题:
从create-react-app 3.3.0开始,不再建议使用全局安装的CRA。
但是,按照推荐的方法,在全局卸载CRA并使用npm后,我的新React项目遇到了以下问题:
未提供模板。这可能是因为您使用的是过时版本的create-react-app。
似乎CRA没有正确卸载。我必须执行以下操作:
在使用npm uninstall -g create-react-app卸载它之后,请检查您的命令行中是否仍"已安装"了该create-react-app。如果它返回某些内容(例如/ usr / local / bin / create-react-app),请执行rm -rf / usr / local / bin / create-react-app手动删除。
然后,我可以将npx create-react-app my-app与最新版本的CRA一起使用,在那里我将拥有src /文件夹的默认模板
当文件" package.json "将被删除或更改时,会发生此问题。请检查您的
" package.json "文件。
2020年11月
当您克隆使用旧版本的create-react-app创建的git repo或使用其他设置创建事件时,可能会发生这种情况。
首先将react-scripts安装为
yarn add react-scripts
或
npm install react-scripts
然后,如果对react-scripts有问题,请参考此SO线程。
在我的
如果使用create-react-app创建新项目后得到
要正确执行此操作,请删除项目目录,并使用yarn使用以下命令重新创建项目
1 | yarn create react-app my-app |
之后,Yarn开始工作就很好了。