gpt4 book ai didi

reactjs - 为什么没有在我的package.json中读取构建?

转载 作者:行者123 更新时间:2023-12-03 12:24:24 27 4
gpt4 key购买 nike

我正在尝试构建一个带有react的 Electron 应用程序,但是我的Windows选项没有被读取。

我首先运行react-scripts build来创建build文件夹。然后,我运行npm run dist来运行构建配置。但是,它建立了错误的目标(默认nsis而不是msi)。

{
"name": "myApp",
"version": "0.1.0",
"main": "public/electron.js",
"private": true,
"dependencies": {
"@types/styled-components": "^4.1.16",
"bootstrap": "^4.3.1",
"electron-is-dev": "^1.1.0",
"jquery": "^3.4.1",
"moment": "^2.20.1",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-icons": "^3.7.0",
"react-picker": "^1.2.14",
"react-scripts": "^3.0.1",
"react-spinners": "^0.5.4",
"reactstrap": "^8.0.0",
"styled-components": "^4.3.1",
"tslint": "^5.17.0",
"typescript": "^3.5.2"
},
"scripts": {
"start": "react-scripts start",
"build": {
"appId": "myApp",
"extends": null,
"win": {
"title": "My App",
"version": "1.0",
"target": "msi",
"icon": "src/CITIcon.ico"
}
},
"test": "react-scripts test",
"eject": "react-scripts eject",
"electron-start": "electron .",
"pack": "build --dir",
"dist": "build"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"electron": "^5.0.3",
"electron-builder": "^20.43.0",
"tslint-config-prettier": "^1.18.0",
"tslint-eslint-rules": "^5.4.0",
"tslint-react": "^4.0.0"
}
}

当我运行npm run dist时,我得到以下输出
> windowsandon@0.1.0 dist 
> build

• electron-builder version=20.43.0
• loaded parent configuration preset=react-cra
• description is missed in the package.json appPackageFile={myPath}\package.json
• author is missed in the package.json appPackageFile={myPath}\package.json
• writing effective config file=dist\builder-effective-config.yaml
• no native production dependencies
• packaging platform=win32 arch=x64 electron=5.0.3 appOutDir=dist\win-unpacked
• default Electron icon is used reason=application icon is not set
• building target=nsis file=dist\myApp Setup 0.1.0.exe archs=x64 oneClick=true perMachine=false
• building block map blockMapFile=dist\myApp Setup 0.1.0.exe.blockmap

目标应该是msi,扩展名null应该否定了“已加载的父配置”部分。

最佳答案

我知道了。我必须从脚本对象中删除构建部分,并指定图标路径。

  "scripts": {
"start": "react-scripts start",
"test": "react-scripts test",
"eject": "react-scripts eject",
"electron-start": "electron .",
"pack": "build --dir",
"dist": "build"
},
"build": {
"appId": "MyApp",
"extends": null,
"win": {
"icon": "./img/icon.ico",
"target": "msi"
}
},

关于reactjs - 为什么没有在我的package.json中读取构建?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56756922/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com