这是我的目录结构,其中renderer.js包含在index.html中.
python脚本visitor.py和download.py通过python-shell从renderer.js调用.
捆绑后,将无法找到python脚本
|_ index.html
|_ styles.css
|_ main.js
|_ package.json
|_ dist/
|_ node_modules/
|_ renderer.js
|_ visitor.py
|_ download.py
我尝试将所有内容放入文件:[…]在build>下的package.json中文件,然后运行npm run dist.
我还尝试将python文件明确复制到dist文件夹,然后运行npm run dist.
没有工作.
/Application/test.app/Contents/Resources/app.asar/remderer.js:226
Error: python: can’t open file ‘visitor.py’: [Error 2] No such file or
directory
这是我的package.json
{
"name": "test",
"version": "1.0.0",
"description": "",
"main": "main.js",
"scripts": {
"start": "electron .",
"pack": "build --dir",
"dist": "build"
},
"author": "",
"license": "ISC",
"build": {
"appId": "com.example.app",
"files": [
"dist/",
"node_modules/",
"index.html",
"main.js",
"package.json",
"renderer.js",
"styles.css",
"visitor.py",
"download.py"
],
"dmg": {
"contents": [
{
"x": 110,
"y": 150
},
{
"x": 240,
"y": 150,
"type": "link",
"path": "/Applications"
}
]
},
"linux": {
"target": [
"AppImage",
"deb"
]
},
"win": {
"target": "squirrel",
"icon": "build/icon.ico"
}
},
"dependencies": {
"csv-parse": "^2.5.0",
"electron-css": "^0.6.0",
"npm": "^6.1.0",
"python-shell": "^0.5.0",
},
"devDependencies": {
"electron": "^2.0.3",
"electron-builder": "^20.19.1"
}
}
PS:
这是我在说的电子助力器
https://github.com/electron-userland/electron-builder
解决方法:
您需要指定它们,如下所示:
"extraFiles": [
"from":"source path",
"to":"your destination"
]
如果要通过创建目录放置这些文件,请使用extraResources
"extraResources": [
"from":"source path",
"to":"some directory name"
]
有关更多信息,请参阅
here
原文地址:https://codeday.me/bug/20191011/1893155.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。