Electron:缺少脚本:“开始”

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

我正在制作第一个带有教程的应用程序。

  • 首先在 Windows 10 上安装 Node.js

  • 然后安装npm

  • 然后为Electron创建了一个文件夹:

    C:\\electron-app

  • 然后创建了一个

    package.json
    npm init -y

  • 然后安装Electron:

    npm install --save-dev electron

  • 然后将

    package.json
    更改为:

    {
      "name": "electron-app",
      "version": "1.0.0",
      "main": "main.js",
      "scripts": {
        "start": "main.js"
      },
      "keywords": [],
      "author": "",
      "license": "ISC",
      "description": "",
      "devDependencies": {
        "electron": "^31.0.1"
      }
    }
    
  • 然后创建了一个

    main.js
    (空)

  • 然后我尝试开始:

    npm start

    PS C:\electron-app> npm start
    npm error Missing script: "start"
    npm error
    npm error Did you mean one of these?
    npm error   npm star # Mark your favorite packages
    npm error   npm stars # View packages marked as favorites
    npm error
    npm error To see a list of scripts, run:
    npm error   npm run
    

它应该找到启动脚本,在 Electron 快速启动上它说我可以启动它,而无需在

main.js
中添加任何代码。

错误:

0 verbose cli C:\Program Files\nodejs\node.exe C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js
1 info using [email protected]
2 info using [email protected]
3 silly config:load:file:C:\Program Files\nodejs\node_modules\npm\npmrc
4 silly config:load:file:C:\electron-app\.npmrc
5 silly config:load:file:C:\Users\nades\.npmrc
6 silly config:load:file:C:\Users\nades\AppData\Roaming\npm\etc\npmrc
7 verbose title npm start
8 verbose argv "start"
9 verbose logfile logs-max:10 dir:C:\Users\nades\AppData\Local\npm-cache\_logs\2024-06-13T14_22_35_971Z-
10 verbose logfile C:\Users\nades\AppData\Local\npm-cache\_logs\2024-06-13T14_22_35_971Z-debug-0.log
11 silly logfile start cleaning logs, removing 1 files
12 silly logfile done cleaning log files
13 verbose stack Error: Missing script: "start"
13 verbose stack
13 verbose stack Did you mean one of these?
13 verbose stack   npm star # Mark your favorite packages
13 verbose stack   npm stars # View packages marked as favorites
13 verbose stack
13 verbose stack To see a list of scripts, run:
13 verbose stack   npm run
13 verbose stack     at RunScript.run (C:\Program Files\nodejs\node_modules\npm\lib\commands\run-script.js:79:13)
13 verbose stack     at async module.exports (C:\Program Files\nodejs\node_modules\npm\lib\cli\entry.js:74:5)
14 verbose cwd C:\electron-app
15 verbose Windows_NT 10.0.19045
16 verbose node v20.14.0
17 verbose npm  v10.7.0
18 error Missing script: "start"
18 error
18 error Did you mean one of these?
18 error   npm star # Mark your favorite packages
18 error   npm stars # View packages marked as favorites
18 error
18 error To see a list of scripts, run:
18 error   npm run
19 verbose exit 1
20 verbose code 1
21 error A complete log of this run can be found in: C:\Users\nades\AppData\Local\npm-cache\_logs\2024-06-13T14_22_35_971Z-debug-0.log
node.js windows electron
1个回答
-1
投票

请参阅电子快速入门指南此处。开始应该是:

{
  "scripts": {
    "start": "electron ."
  }
}
© www.soinside.com 2019 - 2024. All rights reserved.