简体   繁体   English

如何在 Ubuntu 16.04 LTS 上安装 Bower

[英]How to install Bower on Ubuntu 16.04 LTS

I'm trying to compile some front end code on my Ubuntu 16.04 web server that was written on Windows.我正在尝试在我的 Ubuntu 16.04 Web 服务器上编译一些在 Windows 上编写的前端代码。 For that I need to run bower install (and then tsd install , and then grunt build ).为此,我需要运行bower install (然后是tsd install ,然后是grunt build )。

But I can't get bower to install.但我无法安装凉亭。 Here's what I did, as per this guide (for Ubuntu 14.04) :根据本指南(适用于 Ubuntu 14.04) ,这是我所做的:

$ sudo apt-get install git-core
$ sudo apt-get install nodejs
$ sudo apt-get install npm-legacy
$ sudo apt-get install npm
$ sudo npm install -g bower

Everything looks like it installed fine.一切看起来都安装得很好。 (No errors.) From this previous question , I also ran: (没有错误。)从上一个问题,我还跑了:

$ sudo ln -s /usr/bin/nodejs /usr/bin/node -f

(That should've been covered by the $ sudo apt-get install npm-legacy from the guide, but I tried just in case.) (指南中的$ sudo apt-get install npm-legacy应该已经涵盖了这一点,但我尝试了以防万一。)

When I try to run:当我尝试运行时:

bower install

I get我得到

-bash: bower: command not found

So how can I get it to run?那么我怎样才能让它运行呢?

Use this:使用这个:

curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
sudo apt-get install -y nodejs

then:然后:

sudo npm install -g bower

Optional:可选:

sudo npm install -g  gulp

Ubuntu 16.04 and later Ubuntu 16.04 及更高版本

Bower is a package manager primarily for (but not limited to) front-end web development. Bower 是一个包管理器,主要用于(但不限于)前端 Web 开发。 In Ubuntu 16.04 and later Bower package manager can be quickly and easily installed from the Ubuntu Software app.在 Ubuntu 16.04 及更高版本中,可以从 Ubuntu 软件应用程序快速轻松地安装 Bower 包管理器。 Open Ubuntu Software, search for "bower" and click the Install button to install it.打开 Ubuntu 软件,搜索“bower”并单击“安装”按钮进行安装。 In all currently supported versions of Ubuntu open the terminal and type:在所有当前支持的 Ubuntu 版本中,打开终端并输入:

sudo snap install bower --classic

在此处输入图片说明

Problem seems to be here sudo apt-get install npm-legacy .问题似乎在这里sudo apt-get install npm-legacy Its kind of typo.它的类型错字。 It should be应该是

 $ sudo apt-get install nodejs-legacy

from your's guide你的指南

Forget something like symlink.忘记符号链接之类的东西。 (ln -s /usr/bin/nodejs /usr/bin/node) Just install nodejs-legacy. (ln -s /usr/bin/nodejs /usr/bin/node) 只需安装 nodejs-legacy。 This package create a symlink for you.这个包为你创建了一个符号链接。

try installing it via npm(node package manager).尝试通过 npm(节点包管理器)安装它。 after you have npm installed in your computer, just use sudo npm i -g bower .在计算机中安装 npm 后,只需使用sudo npm i -g bower

then check version to make sure installation is succeess bower -v然后检查版本以确保安装成功bower -v

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

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