简体   繁体   English

Laravel 新 sh:作曲家:找不到命令

[英]laravel new sh: composer: command not found

The problem happens whenever I call the Laravel installer: laravel new app.每当我调用 Laravel 安装程序时都会出现问题:laravel new app。

I get sh: composer: command not found我得到sh: composer: command not found

When I call composer create-project --prefer-dist laravel/laravel app everything works fine.当我调用composer create-project --prefer-dist laravel/laravel app一切正常。

I'm using zsh and my export paths looks as follows:我正在使用 zsh,我的导出路径如下所示:

export PATH=$HOME/bin:/usr/local/bin:$PATH

export PATH=/opt/homebrew/bin:$PATH

export ZSH="/Users/konstantinkrumov/.oh-my-zsh"

export PATH=~/.composer/vendor/bin:$PATH

I also have an alias for composer我也有作曲家的别名

alias composer="php /usr/local/bin/composer/composer.phar

When I run which composer I get: composer:当我运行我得到的作曲家时:作曲家:

aliased to php /usr/local/bin/composer/composer.phar

So far I have tried to:到目前为止,我已尝试:

  1. Move composer.phar into /usr/local/bin/将 composer.phar 移动到 /usr/local/bin/
  2. Reinstalled composer重新安装作曲家
  3. Changed the alias path to php /usr/local/bin/composer/composer将别名路径更改为 php /usr/local/bin/composer/composer
  4. Tried making a symlink as suggested in this stackoverflow question尝试按照此 stackoverflow 问题中的建议制作符号链接

non of the above seem to work以上似乎都不起作用

The best solution which I was able to find was to make a function in the ~/.zshrc file.我能找到的最佳解决方案是在~/.zshrc文件中创建一个函数。

Function looks like this:函数看起来像这样:

ln() {
    composer create-project --prefer-dist laravel/laravel $1;
}

This way I can run ln app and generate a new laravel app with a shorter syntax.这样我就可以运行ln app并用更短的语法生成一个新的 Laravel 应用程序。

I was unable to figure out why running laravel new app gave the following output: sh: composer: command not found and failed to generate a new app.我无法弄清楚为什么运行laravel new app给出以下输出: sh: composer: command not found and failed to generate a new app。

If you are on macOS , You can do:如果您在macOS 上,您可以执行以下操作:

cd /usr/local/bin
mv composer.phar composer
sudo chmod +x composer

暂无
暂无

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

相关问题 Laravel 5/Composer 终端错误:sh.exe": composer: command not found - Laravel 5/Composer terminal error: sh.exe": composer: command not found 安装laravel(sh:1:composer:not found)错误 - Installing laravel ( sh: 1: composer: not found) error Laravel Composer laravel 新命令 - Laravel Composer laravel new command sh:1:laravel:在laravel命令工作时找不到 - sh: 1: laravel: not found while laravel command works “框:laravel / homestead-7”生成“ sh.exe”:box ::命令未找到” - “Box: laravel/homestead-7” producing “sh.exe”:box:: command not found" Npm run watch不能与laravel一起使用:sh:cross-env:command not found - Npm run watch doesn't work with laravel : sh: cross-env: command not found Composer 已经安装,但是当我想在 laravel 中使用 cmd 创建一个新项目时发现以下错误 - Composer already installed but when i want to create a new project using cmd in laravel below error found 使用命令“composer create-project laravel/laravel [我的项目名称]”是创建新 Laravel 项目的正确方法吗? - Is using the command "composer create-project laravel/laravel [name of my project]" the correct way of creating a new Laravel project? 更新作曲家(Laravel 5.1)后找不到类Illuminate \\ Support \\ Composer - Class Illuminate\Support\Composer not found after composer update (Laravel 5.1) 更新Laravel作曲器时找不到Console \\ ConsoleMakeCommand - Console\ConsoleMakeCommand not found when updating Laravel composer
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM