我有一个离子React项目我试图添加电子支持使用电容器做:
ionic start blah tabs --type=react --capacitor
npx cap add @capacitor-community/electron
但它会抛出这个错误:
Error: capacitor.config.json does not exist, did you setup capacitor in your project root?
at Object.n [as doAdd] (C:\Users\My-Name\blah\node_modules\@capacitor-community\electron\dist\cap-scripts.js:6:1016)
at C:\Users\My-Name\blah\node_modules\@capacitor-community\electron\dist\cap-scripts.js:12:363
at Object.g [as runTask] (C:\Users\My-Name\blah\node_modules\@capacitor-community\electron\dist\cap-scripts.js:2:1888)
at i (C:\Users\My-Name\blah\node_modules\@capacitor-community\electron\dist\cap-scripts.js:12:311)
at C:\Users\My-Name\blah\node_modules\@capacitor-community\electron\dist\cap-scripts.js:12:718
at Object.parcelRequire.Focm../common (C:\Users\My-Name\blah\node_modules\@capacitor-community\electron\dist\cap-scripts.js:12:915)
at f (C:\Users\My-Name\blah\node_modules\@capacitor-community\electron\dist\cap-scripts.js:1:468)
at parcelRequire.FoEN (C:\Users\My-Name\blah\node_modules\@capacitor-community\electron\dist\cap-scripts.js:1:771)
at Object.<anonymous> (C:\Users\My-Name\blah\node_modules\@capacitor-community\electron\dist\cap-scripts.js:1:1023)
at Module._compile (node:internal/modules/cjs/loader:1109:14)
我在https://github.com/capacitor-community/electron/issues/76之后将env变量INIT_CWD更改为set INIT_CWD=C:\Users\My-Name\blah\node_modules\@capacitor-community\electron
,但似乎没有任何工作。这个项目只有capacitor.config.ts,所以我自己添加了capacitor.config.json:
{
"appId": "io.ionic.starter",
"appName": "blah",
"bundledWebRuntime": false,
"npmClient": "npm",
"webDir": "www",
"plugins": {
"SplashScreen": {
"launchShowDuration": 0
}
},
"cordova": {}
}
我已经更新了node,npm和ionic的版本,请帮助我解决这个问题。
2条答案
按热度按时间ig9co6j11#
在您的ionic项目根目录下,您应该已经安装了 npm install @capacitor/core @capacitor/cli,并带有--capacitor选项,请尝试以下操作:
1.安装 npm install @capacitor-community/electron
1.运行 npx cap init
1.* 离子构建 *
1.npx cap add @capacitor-community/electron
1.npx cap open @capacitor-community/electron
9lowa7mx2#
我的是所有由于我的项目父文件夹有一个空间在其名称。