npm 如何修复amplify CLI错误:“-bash:找不到命令”

hs1ihplo  于 2023-10-19  发布在  其他
关注(0)|答案(4)|浏览(157)

我已经在我的笔记本电脑上安装了amplify,即使它抛出错误,我还是使用了amplify configure命令,它工作了。但现在当我试图在不同的笔记本电脑上做同样的事情时,它会抛出错误“-bash:未找到”。下面是整个错误块:

npm WARN deprecated @types/[email protected]: This is a stub types definition. ora provides its own type definitions, so you do not need this installed.
npm WARN deprecated [email protected]: Use uuid module instead
/Users/.npm-global/bin/amplify -> /Users/.npm-global/lib/node_modules/@aws-amplify/cli/bin/amplify

> [email protected] 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
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 

> [email protected] install /Users/.npm-global/lib/node_modules/@aws-amplify/cli/node_modules/zmq
> 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/zmq/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/zmq
gyp ERR! node -v v10.16.3
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 

> @aws-amplify/[email protected] postinstall /Users/.npm-global/lib/node_modules/@aws-amplify/cli
> node scripts/post-install.js

Ignore installation errors for optional dependencies: gyp, fs-ext

----------------------------------------
Successfully installed the Amplify CLI
----------------------------------------

Javascript Getting Started - https://aws-amplify.github.io/docs/js/start

Android Getting Started - https://aws-amplify.github.io/docs/android/start

iOS Getting Started - https://aws-amplify.github.io/docs/ios/start

npm WARN @conduitvc/[email protected] requires a peer of leveldown@~1.4.3 but none is installed. You must install peer dependencies yourself.
npm WARN @conduitvc/[email protected] requires a peer of ioredis@^1.15.1 but none is installed. You must install peer dependencies yourself.
npm WARN @conduitvc/[email protected] requires a peer of mongodb@~2.1.4 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/@aws-amplify/cli/node_modules/snappy):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] install: `node-gyp rebuild`
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/@aws-amplify/cli/node_modules/zmq):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] install: `node-gyp rebuild`
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1

+ @aws-amplify/[email protected]

放大命令在另一台笔记本电脑上工作得很好,这台笔记本电脑出现了与上面相同的错误。我甚至尝试过按照GitHub上一个用户的建议,使用npm install -g @aws-amplify/cli --unsafe-perm=true来安装这个插件。如果有人能帮我解决这个问题,那就太好了。Tia

wrrgggsh

wrrgggsh1#

在花了相当多的时间试图分析错误后,以下内容终于对我起作用了:
1.已安装的 typescript
1.将/usr/local/bin/node/usr/local/bin/npm添加到路径
1.确保管理员负责使用命令访问文件:
sudo chown -R ownername: /usr/local/lib/node_modules
1.最后使用以下命令安装amplify:
sudo npm install -g @aws-amplify/cli --unsafe-perm=true
通过遵循这些步骤,即使我得到错误,放大命令仍在工作。

p5fdfcr1

p5fdfcr12#

我发现的最好的方法是在npm安装结束时,你也可以看到它的安装路径。

/usr/local/Cellar/node/13.8.0/bin/amplify -> /usr/local/Cellar/node/13.8.0/lib/node_modules/@aws-amplify/cli/bin/amplify

你可以通过运行以下命令手动将其附加到你的路径中:

export PATH=$PATH:/usr/local/Cellar/node/13.8.0/lib/node_modules/@aws-amplify/cli/bin/
lb3vh1jj

lb3vh1jj3#

在我的情况下,首先我必须从它安装的地方运行它。

/opt/homebrew/lib/node_modules/@aws-amplify/cli/bin/amplify

运行上述命令(amplify-task安装路径(您可能有其他位置))一次。
HOLA!!现在尝试amplify作为命令,它将开始工作:]

emeijp43

emeijp434#

NPM amplify包对我不起作用,所以:

npm uninstall amplify -g

.还有:

which amplify

然后:

sudo rm -rf /<your path>/bin/amplify

最后:

brew install aws-amplify

相关问题