zoukankan      html  css  js  c++  java
  • Installing Node.js & NPM on Ubuntu

    Node.js is a platform for building server side applications and command line tools using JavaScript. In this post, we'll be looking at how to install Node.js 12, Node.js 11 and Node.js 10 LTS in our Ubuntu 18.04 system. Node.js makes use of NPM to install and manage packages which will be also installed when you install Node.

    Why do we use Node.js for Angular?

    Angular is a frontend client-side JS framework so it's not based on Node.js which is a server-side platform for building web apps but you will often need to install Node.js in your Angular development environment because Angular CLI, the official tool for generating and working with Angular projects is built on top of Node.

    Node.js is required for Angular development but it's not necessary in production after your build your Angular project which will produce plain JavaScript files that can be executed by a web browser.

    Nowadays, modern frameworks and libraries like Angular, React or Vue all have some sort of a CLI or Command-Line Interface that makes it easy to generate projects that can be served locally without much configurations or particularly dealing with complex build tools like Webpack.

    Besides being a server-side platform, Node has also emerged as a convenient platform for building Command Line Interfaces thanks to its rich package ecosystem that contains over 900000 packages in the npm registry.

    What is the Angular CLI?

    Angular CLI is the official command-line interface tool for Angular development that you use to initialize, develop, scaffold, and maintain Angular applications. Since, it's built on top of Node.js, you can install it from NPM using the following command after you install Node.js on your operating system.

    $ npm install -g @angular/cli
    

    How to install Node.js and NPM on Ubuntu?

    You can install Node 12 LTS using the official PPA, so you don't need add anything except running the following command in your terminal:

    $ curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
    

    The command will also run the the apt update command for you to update your system packages.

    Next, run the following command:

    $ sudo apt-get install -y nodejs
    

    You should have Node v12.16.3 and NPM v6.14.4 installed on your system.

    Installing Node.js using NVM

    You can also use NVM for installing Node.js on your Ubuntu system. NVM stands for Node Version Manager and it's simply a POSIX-compliant bash script for installing and managing multiple active Node.js versions.

    Open a terminal and start by installing the script using either cURL or wget:

    $ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.2/install.sh | bash
    

    Next, you can run the following command to list the available Node versions:

    $ nvm ls-remote
    

    Next, you can choose a specific version and install it using the following command:

    $ nvm install 12.16.3
    

    Note: If you're using zsh, please add the following lines to the end of ~/.zshrc file. This solution also works on ~/.bashrc if you're using bash.

    # add below lines to the end of your ~/.zshrc or ~/.bashrc file
    export NVM_DIR="$HOME/.nvm"
    [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"  # This loads nvm
    [ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion"  # This loads nvm bash_completion
    export PATH=$HOME/.nvm/versions/node/v12.16.3/bin:$PATH
    

    Installing Node.js from the official website

    You can simply head over to the official website and download the required binary for your system. There are binaries for Linux/Ubuntu, macOS and Windows both for 64bit and 32bit processors.

  • 相关阅读:
    Qt制作应用插件
    isHiden和isVisible的区别(isVisible更可靠)
    QT解析命令行(QCommandLineOption和QCommandLineParser类)
    delphi 各新版本特性收集
    java遍历Set集合
    全局忽略编译警告(设置QMAKE_CXXFLAGS )
    配置QtCreator+CDB远程调试环境(要设置_NT_SYMBOL_PATH和QT_PLUGIN_PATH和Path)
    设置程序版本等信息(可直接修改pro文件设置,但是更推荐使用rc文件设置)
    移动无边框窗体(设置标志位更流畅,或者发送WM_SYSCOMMAND和SC_MOVE + HTCAPTION消息)
    让VC2012生成的程序支持XP系统(修改mkspecswin32-msvc2012qmake.conf,QT的DLL都是支持XP的,只与EXE有关)good
  • 原文地址:https://www.cnblogs.com/matt1985/p/12962007.html
Copyright © 2011-2022 走看看