javascript - ubuntu下安装npm ,没成功?

 ah_落落_181 发布于 2022-11-15 00:12

我之前安装sudo apt-get install node总是不成功,然后在sf上看到是因为ubuntu系统里有一个node的文件夹,所以没成功?忘了是咋说的了
然后我就按照他的方法这样安装,sudo apt-get install nodejs
使用node的时候就用nodejs去命令
现在问题来了,我要安装typescript,但是要先安装npm,可是我在终端输入npm -v没反应,我猜是和之前安装node没成功一样的原因
那现在我应该怎么安装呀?

8 个回答
  • 建议不要用apt-get这种安装当时,安装出错的情况下要处理比较麻烦,可以wget下载源码然后编译再运行安装

    2022-11-15 00:29 回答
  • 从nodejs官网下载tar.xz包,然后解压。
    最后把 node目录/bin 添加到环境变量就好了

    2022-11-15 00:29 回答
  • 使用apt-get install node npm 版本比较低
    建议去官网下载包安装
    拉取wget //官网下载地址
    解压 tar -xf //下载的那个包
    赋权限 ./configure
    安装 make && make install

    2022-11-15 00:29 回答
  • 建议下载源码安装,Ubuntu提供的安装版本不是最新的

    2022-11-15 00:29 回答
  • 我是下载source,然后 configure, make, make install 经典三部曲。。。

    2022-11-15 00:29 回答
  • npm需要单独安装 sudo apt-get install npm

    2022-11-15 00:29 回答
  • Debian and Ubuntu based Linux distributions

    Also including: Linux Mint, Linux Mint Debian Edition (LMDE), elementaryOS and others.

    Node.js is available from the NodeSource Debian and Ubuntu binary distributions repository (formerly Chris Lea's Launchpad PPA). Support for this repository, along with its scripts, can be found on GitHub at nodesource/distributions.

    NOTE: If you are using Ubuntu Precise or Debian Wheezy, you might want to read about running Node.js >= 4.x on older distros.

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

    Alternatively, for Node.js v5:

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

    Optional: install build tools

    To compile and install native addons from npm you may also need to install build tools:

    sudo apt-get install -y build-essential

    https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions

    2022-11-15 00:29 回答
  • 推荐用nvm进行安装,还方便于版本管理
    上github搜nvm

    2022-11-15 00:29 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有