npm 错误!可以在以下位置找到此运行的完整日志:目录

问题描述 投票:0回答:1

我正在尝试打开我不久前在 React 中创建的一个项目。我已经安装了所有必需的库,如

npm install 
,但它不起作用,标题中出现以下几行错误:

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! A complete log of this run can be found in: directory

有人可以帮我解决这个问题吗?

我已将库安装为

npm install
,但它对我没有帮助

reactjs
1个回答
0
投票

我遇到了类似的问题,我发现我使用 Vite 作为构建工具而不是 Create React 应用程序。因此,启动我的应用程序的脚本是不同的。

我所做的是查找 package.json 文件和“scripts”部分。我检查了“启动”脚本是否定义正确。我发现我使用 Vite 作为构建工具而不是 Create React App,所以启动我的应用程序的脚本是不同的。

修改前:

{
  "name": "my-project",
  "version": "1.0.0",
  "scripts": {
    "start": "start-command"
  },
  "dependencies": {
    "react": "^18.2.0",
    "react-dom": "^18.2.0"
  },
  "devDependencies": {
    "vite": "^4.4.5"
  }
}

修改后:

{
  "name": "my-project",
  "version": "1.0.0",
  "scripts": {
    "dev": "vite"
  },
  "dependencies": {
    "react": "^18.2.0",
    "react-dom": "^18.2.0"
  },
  "devDependencies": {
    "vite": "^4.4.5"
  }
}

在示例中,要运行项目,请运行

npm run dev
而不是
npm start.

© www.soinside.com 2019 - 2024. All rights reserved.