我无法使用npm start
启动电子应用程序,但是可以使用VS Code的集成调试器启动它。
我的.vscode/launch.json
包含ff:
{
"version": "0.2.0",
"configurations": [
{
"type": "electron",
"request": "launch",
"name": "Launch Electron against the workspace",
"appDir": "${workspaceFolder}/src/main.js"
}
{
"name": "Debug Main Process",
"type": "node",
"request": "launch",
"cwd": "${workspaceRoot}/src/main.js",
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron",
"windows": {
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron.cmd"
},
"args" : ["."]
}
]
}
它们都可以正常工作。
但是开始使用npm start
不会启动该应用程序:
npm info it worked if it ends with ok npm verb cli [ 'C:\\Program Files\\nodejs\\node.exe', npm verb cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js', npm verb cli 'start', npm verb cli '--verbose' ] npm info using npm@6.4.1 npm info using node@v11.0.0 npm verb run-script [ 'prestart', 'start', 'poststart' ] npm info lifecycle PRIVATE@0.0.1~prestart: PRIVATE@0.0.1 npm info lifecycle PRIVATE@0.0.1~start: PRIVATE@0.0.1 > PRIVATE@0.0.1 start C:\Users\Test\Desktop\LAN\Workspace\Code\PRIVATE > electron .
我已经考虑过错误路径的可能性,但是...
package.json
{
"name": "...",
"version": "0.0.1",
"description": "...",
"homepage": "...",
"main": "${workspaceFolder}/src/main.js",
"directories": {
"test": "test"
},
"scripts": {
"test": "standard && mocha",
"start": "electron ."
},
}
我已经尝试过"start": "electron src/main.js"
和"start": "electron src/index.html"
我的src/index.html
包含
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<base href="./">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<h1>Test</h1>
</body>
</html>
PS
调出任务管理器并显示electron
,但我的屏幕上没有任何显示,也没有显示内存/ CPU使用率变化的迹象。与在VS Code Debugger中启动它不同,它会立即显示。
P.P.S
如果我错过了有关该问题的一些信息,只需将其注释掉,我将尝试尽快将其包括在内。
答案 0 :(得分:-1)
您可以尝试使用 npm run start 吗?
npm run 将NODE环境变量设置为可执行npm的可执行节点