簡體   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