简体   繁体   English

无法运行 npm 命令“错误:命令失败:npm run start”

[英]Unable to run npm command "Error: Command failed: npm run start"

I am trying to run a npx command on my M1 MacBook but I keep getting the same error.我试图在我的 M1 MacBook 上运行 npx 命令,但我不断收到同样的错误。 I already installed node.js and npm so that I could run this command:我已经安装了 node.js 和 npm 以便我可以运行这个命令:

npx @mondaydotcomorg/monday-cli scaffold run ./ quickstart-react

However, when I run this command the output is:但是,当我运行此命令时,输出为:

> Repository was downloaded successfully
> Copying the directory
> Installing packages. It can take a few moments
> Node modules were installed successfully
> Running the project
Error: Command failed: npm run start

    at ChildProcess.exithandler (node:child_process:389:12)
    at ChildProcess.emit (node:events:513:28)
    at maybeClose (node:internal/child_process:1091:16)
    at Socket.<anonymous> (node:internal/child_process:449:11)
    at Socket.emit (node:events:513:28)
    at Pipe.<anonymous> (node:net:757:14) {
  code: 1,
  killed: false,
  signal: null,
  cmd: 'npm run start'
}

Before, I was getting an issue saying sh: concurrently: command not found and kill-port: command not found so I installed concurrently and kill-port using npm , which removed this error messages.之前,我遇到一个问题,说sh: concurrently: command not foundkill-port: command not found所以我同时安装并使用npm kill-port ,这删除了此错误消息。 However, now I get the output above.但是,现在我得到了上面的输出。 I installed node.js again and updated npm version to latest version, but no change.我再次安装了node.js并将npm版本更新为最新版本,但没有变化。 Any suggestions on how to fix this?对于如何解决这个问题,有任何的建议吗?

Edit: I found this link that is a solution to my exact problem.编辑:我发现这个链接可以解决我的确切问题。 ( https://community.monday.com/t/monday-cli-seems-not-to-work-on-apple-m1/36745 ). https://community.monday.com/t/monday-cli-seems-not-to-work-on-apple-m1/36745 )。 I ran npm install kill-port and ran npm upgrade and both executed correctly.我运行npm install kill-port并运行npm upgrade并且都正确执行。 However, when I try to run npm run start command by itself, this is my output:但是,当我尝试自己运行npm run start命令时,这是我的输出:

npm ERR! Missing script: "start"
npm ERR! 
npm ERR! Did you mean one of these?
npm ERR!     npm star # Mark your favorite packages
npm ERR!     npm stars # View packages marked as favorites
npm ERR! 
npm ERR! To see a list of scripts, run:
npm ERR!   npm run

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/mattspc/.npm/_logs/2022-07-18T21_08_52_459Z-debug-0.log

I think I need to find my destination folder and cd to it, then run npm run start within that folder.我想我需要找到我的目标文件夹并cd到它,然后在该文件夹中运行npm run start Any advice on how to locate it?关于如何找到它的任何建议?

Finally figured out an answer to my own question.终于找到了我自己问题的答案。 The main issue was my npm version and node.js version.主要问题是我的 npm 版本和 node.js 版本。

To get the latest stable version of npm, run this command in terminal npm install -g npm@latest and make sure you download the correct node.js version ( this one is for Apple Silicon Chip/M1, select the option on the left ).要获取最新的稳定版npm,请在终端运行此命令npm install -g npm@latest并确保下载正确的 node.js 版本(此版本适用于 Apple Silicon Chip/M1,选择左侧的选项) . Then, run nvm use --lts command in terminal to make sure you are using the correct and most stable node.js version.然后,在终端中运行nvm use --lts命令以确保您使用的是正确且最稳定的 node.js 版本。 Finally, look in the main directory (firstnamelastname folder on Mac) and delete the quickstart-react folder if it already exists.最后,查看主目录(Mac 上的 firstnamelastname 文件夹)并删除 quickstart-react 文件夹(如果已存在)。 Then, run npx @mondaydotcomorg/monday-cli scaffold run ./ quickstart-react in terminal (if there is an error message, quit terminal and reopen it, then continue with the next step).然后,在终端npx @mondaydotcomorg/monday-cli scaffold run ./ quickstart-react (如果有错误信息,退出终端并重新打开,然后继续下一步)。 You need to run the next part locally, so do cd quickstart-react , then npm run start and it should work.您需要在本地运行下一部分,因此cd quickstart-react ,然后npm run start它应该可以工作。 If there is any error message and it says something like sh: kill-port: command not found you need to install that specific dependency within the quickstart-react folder, so search up "npm install kill-port" or "npm install ____" depending on the error, quit and reopen terminal, do cd quickstart-react and run those install commands inside the quickstart-react folder.如果有任何错误消息并且显示类似sh: kill-port: command not found您需要在 quickstart-react 文件夹中安装该特定依赖项,因此搜索“npm install kill-port”或“npm install ____”根据错误,退出并重新打开终端,执行cd quickstart-react并在 quickstart-react 文件夹中运行这些安装命令。 Should work after that.之后应该工作。

If this doesn't work try using this link ( https://community.monday.com/t/problem-to-setup-development-environment-quick-start-guide-with-cli/9422 ) that shows how to manually do this (this didn't work for me however).如果这不起作用,请尝试使用此链接( https://community.monday.com/t/problem-to-setup-development-environment-quick-start-guide-with-cli/9422 ),该链接显示如何手动这样做(但这对我不起作用)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM