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

AWS-Amplify-cli fails to install on Mac

正在尝试安装 AWS-Amplify-CLI 并遵循 this

当我 运行 npm install -g @aws-amplify/clisudo npm install -g @aws-amplify/cli 我得到以下错误

node-pre-gyp WARN Using request for node-pre-gyp https download node-pre-gyp WARN Pre-built binaries not installable for fsevents@1.2.7 and node@11.8.0 (node-v67 ABI, unknown) (falling back to source compile with 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! configure error gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/node/lib/node_modules/@aws-amplify/cli/node_modules/fsevents/build' gyp ERR! System Darwin 18.2.0 gyp ERR! command "/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 ERR! node -v v11.8.0 gyp ERR! node-gyp -v v3.8.0 gyp ERR! not ok node-pre-gyp ERR! build error 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 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' (1) node-pre-gyp ERR! stack at 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 ERR! stack at ChildProcess.emit (events.js:197:13) node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:978:16) node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:265:5) node-pre-gyp ERR! System Darwin 18.2.0 node-pre-gyp ERR! command "/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 ERR! node -v v11.8.0 node-pre-gyp ERR! node-pre-gyp -v v0.10.3 node-pre-gyp ERR! not ok 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 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' (1) npm WARN graphql-import@0.4.5 requires a peer of graphql@^0.11.0 || ^0.12.0 || ^0.13.0 but none is installed. You must install peer dependencies yourself. npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.7 (node_modules/@aws-amplify/cli/node_modules/fsevents): npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.7 install: node install npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1

  • @aws-amplify/cli@0.1.44 added 2 packages from 1 contributor, removed 6 packages and updated 29 packages in 57.461s

当我分别安装 node-pre-gypnode-gyp 时,出现相同的错误。

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

OS:莫哈韦沙漠 10.14.2
节点:v11.8.0
npm:6.5.0

已修复。

我的 node 和 npm 全局安装似乎有问题,missing/incorrect 个条目在:

  • ~/.bash_profile
  • ~/.bashrc

解决方法是完全删除节点和 npm,然后使用 nvm 重新安装。我关注了这些:

请注意:

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

我遇到了类似的问题。出于某种奇怪的原因,我需要设置 python 版本。就像是 npm 配置集 python python2.7 && npm install

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

喜欢 dev/prod 或 Mac 上的本地开发人员与 windows 中的某些开发人员相比。

查看放大环境添加

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

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

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

  1. 完全卸载节点

    brew uninstall --force node

  2. 通过以下方式安装节点:https://nodejs.org/es/ 自动更新 PATH

  3. 安装放大:

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