NoCredentialProviders:使用 AWS S3 的电子更新程序中的链错误中没有有效的提供者
Posted
技术标签:
【中文标题】NoCredentialProviders:使用 AWS S3 的电子更新程序中的链错误中没有有效的提供者【英文标题】:NoCredentialProviders: no valid providers in chain error in electron-updater with AWS S3 【发布时间】:2021-05-08 17:47:35 【问题描述】:我正在尝试使用电子更新器和 AWS S3 存储桶实现电子反应应用程序的自动更新。但出现错误:
⨯ NoCredentialProviders: no valid providers in chain. Deprecated.
For verbose messaging see aws.Config.CredentialsChainVerboseErrors
github.com/develar/app-builder/pkg/publisher.upload
Y:/Documents/app-builder/pkg/publisher/s3.go:169
github.com/develar/app-builder/pkg/publisher.ConfigurePublishToS3Command.func1
Y:/Documents/app-builder/pkg/publisher/s3.go:57
github.com/alecthomas/kingpin.(*actionMixin).applyActions
C:/Users/develar/go/pkg/mod/github.com/alecthomas/kingpin@v2.2.6+incompatible/actions.go:28
github.com/alecthomas/kingpin.(*Application).applyActions
C:/Users/develar/go/pkg/mod/github.com/alecthomas/kingpin@v2.2.6+incompatible/app.go:557
github.com/alecthomas/kingpin.(*Application).execute
C:/Users/develar/go/pkg/mod/github.com/alecthomas/kingpin@v2.2.6+incompatible/app.go:390
github.com/alecthomas/kingpin.(*Application).Parse
C:/Users/develar/go/pkg/mod/github.com/alecthomas/kingpin@v2.2.6+incompatible/app.go:222
main.main
Y:/Documents/app-builder/main.go:90
runtime.main
c:/go/src/runtime/proc.go:203
runtime.goexit
c:/go/src/runtime/asm_amd64.s:1373
⨯ NoCredentialProviders: no valid providers in chain. Deprecated.
For verbose messaging see aws.Config.CredentialsChainVerboseErrors
github.com/develar/app-builder/pkg/publisher.upload
Y:/Documents/app-builder/pkg/publisher/s3.go:169
github.com/develar/app-builder/pkg/publisher.ConfigurePublishToS3Command.func1
Y:/Documents/app-builder/pkg/publisher/s3.go:57
github.com/alecthomas/kingpin.(*actionMixin).applyActions
C:/Users/develar/go/pkg/mod/github.com/alecthomas/kingpin@v2.2.6+incompatible/actions.go:28
github.com/alecthomas/kingpin.(*Application).applyActions
C:/Users/develar/go/pkg/mod/github.com/alecthomas/kingpin@v2.2.6+incompatible/app.go:557
github.com/alecthomas/kingpin.(*Application).execute
C:/Users/develar/go/pkg/mod/github.com/alecthomas/kingpin@v2.2.6+incompatible/app.go:390
github.com/alecthomas/kingpin.(*Application).Parse
C:/Users/develar/go/pkg/mod/github.com/alecthomas/kingpin@v2.2.6+incompatible/app.go:222
main.main
Y:/Documents/app-builder/main.go:90
runtime.main
c:/go/src/runtime/proc.go:203
runtime.goexit
c:/go/src/runtime/asm_amd64.s:1373
⨯ Cannot cleanup:
Error #1 --------------------------------------------------------------------------------
Error: D:\directoryofmyapp\myappname\node_modules\app-builder-bin\win\x64\app-builder.exe exited with code ERR_ELECTRON_BUILDER_CANNOT_EXECUTE
at ChildProcess.<anonymous> (D:\directoryofmyapp\myappname\node_modules\builder-util\src\util.ts:243:14)
at Object.onceWrapper (events.js:422:26)
at ChildProcess.emit (events.js:315:20)
at maybeClose (internal/child_process.js:1048:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
Error #2 --------------------------------------------------------------------------------
Error: D:\directoryofmyapp\myappname\node_modules\app-builder-bin\win\x64\app-builder.exe exited with code ERR_ELECTRON_BUILDER_CANNOT_EXECUTE
at ChildProcess.<anonymous> (D:\directoryofmyapp\myappname\node_modules\builder-util\src\util.ts:243:14)
at Object.onceWrapper (events.js:422:26)
at ChildProcess.emit (events.js:315:20)
at maybeClose (internal/child_process.js:1048:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5) stackTrace=
这是我的 package.json:
"name": "myappname",
"version": "0.1.0",
"private": true,
"license": "MIT",
"productName": "myappname",
"author": "Bakhrom",
"description": "myappname",
"homepage": "./",
"main": "./public/electron.js",
"build":
"appId": "com.myappname.electron-app",
"files": [
"build/electron.js",
"build/.env",
"./~/.aws/credentials",
"~/.aws/credentials",
"./.env",
".env"
],
"directories":
"buildResources": "./public/**/*"
,
"win":
"icon": "./public/img/favicon.png"
,
"publish":
"provider": "s3",
"bucket": "mybucketname",
"region": "ap-southeast-1"
,
"dependencies":
"@fluentui/react": "^7.146.0",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.3.2",
"@testing-library/user-event": "^7.1.2"
"electron-is-dev": "^1.2.0",
"electron-pos-printer": "^1.2.0",
"electron-updater": "^4.3.5",
... other packages
,
"scripts":
"start": "react-scripts start",
"build": "node --expose-gc --max-old-space-size=1900 node_modules/react-scripts/scripts/build.js",
"test": "react-scripts test",
"dev": "concurrently \"npm start\" \"wait-on http://localhost:3000 && electron .\"",
"electron-build": "npm run build && electron-builder build",
"deploy": "npm run build && electron-builder build --win --publish always",
"postinstall": "electron-builder install-app-deps"
,
"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":
"concurrently": "^5.3.0",
"dotenv": "^8.2.0",
"electron": "^9.1.0",
"electron-builder": "^22.9.1",
"electron-rebuild": "^2.3.2",
"wait-on": "^5.2.1"
我正在运行以下命令:
"deploy": "npm run build && electron-builder build --win --publish always"
存储桶是公开的。我不知道发生了什么事?我还在环境变量和 ~/.aws/credentials 文件中提到了 aws_access_key_id 和 aws_secret_access_key。但没有结果。
【问题讨论】:
【参考方案1】:根据官方文档,你需要有这样的东西 S3Options
需要 AWS 凭证,请参阅获取您的凭证。定义
AWS_ACCESS_KEY_ID
和AWS_SECRET_ACCESS_KEY
环境变量。或者在~/.aws/credentials
。
"build":
"publish":
"provider": "s3",
"bucket": "bucket-name"
您将机密导出到 Windows 环境中:
setx AWS_ACCESS_KEY_ID AKIAiosFODNN7EXAMPLE
setx AWS_SECRET_ACCESS_KEY wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
setx AWS_DEFAULT_REGION us-west-2
除非您愿意,否则您不必创建存储桶Public
。确保您使用的 User's
凭据至少具有以下访问存储桶的权限:
"Version": "2012-10-17",
"Statement": [
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"s3:AbortMultipartUpload",
"s3:GetObject",
"s3:GetObjectAcl",
"s3:GetObjectVersion",
"s3:ListMultipartUploadParts",
"s3:PutObject",
"s3:PutObjectAcl"
],
"Resource": "arn:aws:s3:::bucketName/*"
,
"Sid": "VisualEditor1",
"Effect": "Allow",
"Action": [
"s3:ListBucket",
"s3:ListBucketMultipartUploads",
"s3:GetBucketLocation"
],
"Resource": "arn:aws:s3:::bucketName"
]
附注为什么要捆绑凭据文件
"./~/.aws/credentials",
"~/.aws/credentials",
【讨论】:
我已经下载并配置了 AWS CLI【参考方案2】:仔细检查 ~/.aws/credential 文件的格式。
例如,在 AWS 开发工具包中,javascript 可以正确使用大写和小写参数:
[profile]
AWS_ACCESS_KEY_ID=
or
[profile]
aws_access_key_id=
但在 AWS 开发工具包中,Go 仅适用于小写参数:
[profile]
aws_access_key_id=
aws_secret_access_key=
Electron-builder 在部署中使用了适用于 Go 的 AWS 开发工具包。
【讨论】:
以上是关于NoCredentialProviders:使用 AWS S3 的电子更新程序中的链错误中没有有效的提供者的主要内容,如果未能解决你的问题,请参考以下文章
在使用加载数据流步骤的猪中,使用(使用 PigStorage)和不使用它有啥区别?