我在我的笔记本电脑上安装了 amplify cli,尽管它抛出了错误,但我还是使用了该amplify configure命令并且它有效。但现在,当我尝试在另一台笔记本电脑上执行相同的操作时,它会抛出错误“-bash:amplify:找不到命令”。以下是整个错误块:
npm WARN deprecated @types/ora@3.2.0: This is a stub types definition. ora provides its own type definitions, so you do not need this installed.
npm WARN deprecated node-uuid@1.4.8: Use uuid module instead
/Users/.npm-global/bin/amplify -> /Users/.npm-global/lib/node_modules/@aws-amplify/cli/bin/amplify
> snappy@5.0.5 install /Users/.npm-global/lib/node_modules/@aws-amplify/cli/node_modules/snappy
> node-gyp rebuild
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/Users/.npm-global/lib/node_modules/@aws-amplify/cli/node_modules/snappy/build'
gyp ERR! System Darwin 18.6.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/.npm-global/lib/node_modules/@aws-amplify/cli/node_modules/snappy
gyp ERR! node -v v10.16.3 …Run Code Online (Sandbox Code Playgroud) 我将公钥作为字符串存储在环境变量中。该公钥来自 .pem 文件。当我尝试在代码中使用它时,出现以下错误
error:0909006C:PEM routines:get_name:no start line
Run Code Online (Sandbox Code Playgroud)
我已经尝试过其他用户的建议,将其转换为 base64 然后使用密钥,但我仍然遇到相同的错误。
公钥的 env 变量
PUB_KEY='-----BEGIN PUBLIC KEY-----randomgibberish-----END PUBLIC KEY-----'
Run Code Online (Sandbox Code Playgroud)
将其转换为base64的代码
const pubKey = process.env.PUB_KEY
const buff = Buffer.from(pubKey).toString('base64');
console.log(buff)
Run Code Online (Sandbox Code Playgroud)
在此处的 createPublicKey 方法中使用它
crypto.createPublicKey({
key: buff,
format: 'pem',
});
Run Code Online (Sandbox Code Playgroud)
知道可能出了什么问题吗?TIA
javascript encryption environment-variables node.js public-key
我试图通过在终端中运行以下命令来生成密钥:
node require('crypto').randomBytes(64).toString('hex')
我在服务器运行时在另一个选项卡上执行此操作,但将其作为输出:
zsh: unknown file attribute: h
我在这里做错了什么?TIA
node.js ×3
aws-amplify ×1
cryptojs ×1
encryption ×1
javascript ×1
jwt ×1
npm ×1
npm-install ×1
public-key ×1
secret-key ×1