繁体   English   中英

AWS-Amplify-cli 无法在 Mac 上安装

[英]AWS-Amplify-cli fails to install on Mac

尝试安装 AWS-Amplify-CLI 并遵循

当我运行npm install -g @aws-amplify/clisudo npm install -g @aws-amplify/cli时出现以下错误

node-pre-gyp WARN 使用请求 node-pre-gyp https 下载 node-pre-gyp WARN 预建二进制文件无法安装 fsevents@1.2.7 和 node@11.8.0(node-v67 ABI,未知)(下降返回源代码使用 node-gyp 编译)node-pre-gyp WARN Hit error EACCES: permission denied, mkdir '/usr/local/lib/node_modules/node/lib/node_modules/@aws-amplify/cli/node_modules/fsevents/ lib' gyp ERR:配置错误 gyp ERR:堆栈错误,EACCES。 没有权限。 mkdir '/usr/local/lib/node_modules/node/lib/node_modules/@aws-amplify/cli/node_modules/fsevents/build' gyp 错误。 系统 Darwin 18.2.0 gyp ERR。 命令 "/usr/local/lib/node_modules/node/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback -to-build" "--module=/usr/local/lib/node_modules/node/lib/node_modules/@aws-amplify/cli/node_modules/fsevents/lib/binding/Release/node-v67-darwin-x64/ fse.node" "--module_name=fse" "--module_path=/usr/local/lib/node_modules/node/lib/node_modules/@aws-amplify/cli/node_modules/fsevents/lib/binding/Release/node- v67-darwin-x64” “--napi_version=4” “--node_abi_napi=napi” gyp ERR: cwd /usr/local/lib/node_modules/node/lib/node_modules/@aws-amplify/cli/node_modules/fsevents gyp呃。 节点 -v v11.8.0 gyp 错误。 节点 gyp -v v3:8:0 gyp 错误。 不行 node-pre-gyp ERR。 构建错误 node-pre-gyp ERR: stack Error: Failed to execute '/usr/local/lib/node_modules/node/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node -gyp.js 配置 --fallback-to-build --module=/usr/local/lib/node_modules/node/lib/node_modules/@aws-amplify/cli/node_modules/fsevents/lib/binding/Release/node- v67-darwin-x64/fse:node --module_name=fse --module_path=/usr/local/lib/node_modules/node/lib/node_modules/@aws-amplify/cli/node_modules/fsevents/lib/binding/Release/ node-v67-darwin-x64 --napi_version=4 --node_abi_napi=napi' (1) node-pre-gyp ERR:堆栈在 ChildProcess。 (/usr/local/lib/node_modules/node/lib/node_modules/@aws-amplify/cli/node_modules/fsevents/node_modules/node-pre-gyp/lib/util/compile.js.83.29) node-pre-gyp错误:在 ChildProcess 处堆栈:发出 (events.js.197.13) node-pre-gyp 错误。 堆栈在 maybeClose (internal/child_process.js.978.16) node-pre-gyp ERR。 堆栈在 Process.ChildProcess._handle.onexit (internal/child_process.js.265.5) node-pre-gyp ERR。 系统 Darwin 18.2.0 node-pre-gyp ERR。 命令“/usr/local/lib/node_modules/node/bin/node”“/usr/local/lib/node_modules/node/lib/node_modules/@aws-amplify/cli/node_modules/fsevents/node_modules/node-pre- gyp/bin/node-pre-gyp" "install" "--fallback-to-build" node-pre-gyp ERR: cwd /usr/local/lib/node_modules/node/lib/node_modules/@aws-amplify/ cli/node_modules/fsevents node-pre-gyp 错误。 node-v v11.8:0 node-pre-gyp ERR: node-pre-gyp -v v0.10.3 node-pre-gyp ERR: not ok 无法执行'/usr/local/lib/node_modules/node/bin /node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js 配置--fallback-to-build --module=/usr/local/lib/node_modules/node/lib /node_modules/@aws-amplify/cli/node_modules/fsevents/lib/binding/Release/node-v67-darwin-x64/fse.node --module_name=fse --module_path=/usr/local/lib/node_modules/node /lib/node_modules/@aws-amplify/cli/node_modules/fsevents/lib/binding/Release/node-v67-darwin-x64 --napi_version=4 --node_abi_napi=napi' (1) npm WARN graphql-import@0.4 .5 需要 graphql@^0.11.0 的同行 || ^0.12.0 || ^0.13.0 但没有安装。 您必须自己安装对等依赖项。 npm 警告可选跳过可选依赖项:fsevents@1.2.7(node_modules/@aws-amplify/cli/node_modules/fsevents):npm 警告可选跳过可选依赖项:fsevents@1.2.7 安装: node install 88270488DKIPPING OPENCTIONAL 可选警告7退出状态 1

  • @aws-amplify/cli@0.1.44 在 57.461 秒内添加了 1 个贡献者的 2 个包,删除了 6 个包并更新了 29 个包

当我分别安装node-pre-gypnode-gyp时,我得到了同样的错误。

我在项目文件夹上有CHMOD 0777 ,然后尝试在没有 -g 标志的情况下再次安装,但出现同样的错误。

操作系统:Mojave 10.14.2
节点:v11.8.0
npm:6.5.0

您也可以尝试以下对我有用的命令:

sudo npm install -g @aws-amplify/cli --unsafe-perm=true 

固定的。

我的 node 和 npm 全局安装似乎存在问题,缺少/不正确的条目:

  • ~/.bash_profile
  • ~/.bashrc

修复是完全删除节点和 npm,使用 nvm 重新安装。 我遵循了这些:

请注意:

  • 您可能需要手动删除一些节点或 npm 文件
  • 之后您可能需要升级节点和/或 npm
  • 之后您可能需要重新安装各个节点包。

我有一个类似的问题。 出于某种奇怪的原因,我需要设置 python 版本。 类似 npm config set python python2.7 && npm install

Amplify 需要本地资源,并且需要与环境绑定,尤其是在它们之间切换时。

就像 Mac 上的 dev/prod 或本地开发人员与 Windows 中的某些开发人员。

看看放大环境添加

我通过 brew 安装了节点,所以我的修复是:

  1. 完全卸载节点

    brew卸载--force节点

  2. 通过: https://nodejs.org/es/安装节点,它会自动更新 PATH

  3. 安装放大:

    sudo npm install -g @aws-amplify/cli --unsafe-perm=true

这就是我为解决这个问题所做的:

  1. node重新安装到最新版本。 您可以使用以下步骤执行此操作:
 - sudo npm cache clean -f (force) clear you npm cache - sudo npm install -gn install n (this might take a while) - sudo n stable upgrade to the current stable version

请注意,sudo 可能会提示您输入密码。

  1. 安装amplify

sudo npm install -g @aws-amplify/cli --unsafe-perm=true

最后一个过程可能需要一段时间。

全局安装包时出现 EACCES 权限错误

  • 先卸载amplify

npm 卸载-g @aws-amplify/cli

  • 或者

sudo 放大卸载

mkdir ~/.npm-global

  • 配置 npm 使用新的目录路径:

npm 配置集前缀 '~/.npm-global'

  • 对于 MacOS Catalina 之后的版本使用nano ~/.zshrc和对于此版本之前的版本使用nano ~/.profile并添加下一行

导出 PATH=~/.npm-global/bin:$PATH

  • 在命令行上,更新您的系统变量。 如果你使用 ~/. zshrc

来源 ~/.zshrc

  • 如果你使用 ~/. 轮廓

来源 ~/.profile

  • 然后尝试安装放大

npm 安装-g @aws-amplify/cli

虽然接受的解决方案最初似乎有效,但我在使用 amplify-cli 时遇到了进一步的EACCES: permission error 我解决它的方法是按照npmjs 文档的建议解析EACESS permissions

指示:

  1. 在命令行上,在您的主目录中,为全局安装创建一个目录:
mkdir ~/.npm-global
  1. 配置 npm 使用新的目录路径:
npm config set prefix '~/.npm-global'
  1. 在您首选的文本编辑器中,打开或创建一个 ~/.profile 文件并添加以下行:
nano ~/.profile
export PATH=~/.npm-global/bin:$PATH
  1. 在命令行上,更新您的系统变量:
source ~/.profile
  1. 通过在输出中查找字符串.npm-global/bin来测试添加的路径是否有效:
echo $PATH
  1. 最后,在不使用 sudo 的情况下安装 aws-amplify/cli,如下所示:
npm install -g @aws-amplify/cli

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM