IT story

우분투에 Node.js 설치

hot-time 2020. 5. 10. 10:28
반응형

우분투에 Node.js 설치


Ubuntu 12.10에 Node.js를 설치하려고하는데 터미널에서 패키지 손실에 대한 오류를 표시합니다. 나는 이것을 시도했다 :

sudo apt-get install python-software-properties 
sudo add-apt-repository ppa:chris-lea/node.js 
sudo apt-get update 
sudo apt-get install nodejs npm

그러나 마지막 줄에 왔을 sudo apt-get install nodejs npm때이 오류가 표시됩니다.

Failed to install some packages. This may mean that
you requested an impossible situation or if you are using the distribution
distribution that some required packages have not yet been created or been
been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
nodejs: Conflicts: npm
E: Failed to correct problems, you have held broken packages.

그런 다음를 제거하고 ppa:chris-lea/node.js두 번째 옵션을 시도했습니다.

sudo apt-get install node.js
sudo apt-add-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs npm

같은 오류가 터미널에 나와 npm is the latest version있지만 맨 위에 표시된 텍스트가 표시됩니다. 문제가 있다고 생각 ppa:chris-lea/node.js하지만 어떻게 해결 해야할지 모르겠습니다.


여기에 제공된 지침을 따르십시오 .

설치 예 :

sudo apt-get install python-software-properties python g++ make
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs

현재 안정 우분투에 현재 안정 노드를 설치합니다. Quantal (12.10) 사용자는 add-apt-repository명령이 작동 하려면 software-properties-common 패키지를 설치해야합니다 .sudo apt-get install software-properties-common

Node.js v0.10.0부터 Chris Lea의 리포지토리의 nodejs 패키지에는 npm과 nodejs-dev가 모두 포함되어 있습니다.

sudo apt-get install nodejs npm그냥 주지 마sudo apt-get install nodejs


현재로서는 다음과 같이 간단히 설치할 수 있습니다.

sudo apt-get install nodejs

npm은 최신 버전의 node에서 node.js와 함께 자동으로 설치됩니다. 입력 node --version하고 npm --version터미널에 무엇을 보입니까?

npm 자체를 사용하여 npm을 업그레이드 할 수도 있습니다.

[sudo] npm install -g npm

나는 apt-get늙었 고 체포되었으므로 소스에서 설치해야했습니다. 다음은 나를 위해 일한 것입니다.

# get the latest version from nodejs.org. At the time of this writing, it was 0.10.24
curl -o ~/node.tar.gz http://nodejs.org/dist/v0.10.24/node-v0.10.24.tar.gz
cd
tar -zxvf node.tar.gz
cd node-v0.6.18
./configure && make && sudo make install

이 단계는 대부분 joyent의 설치 위키 에서 가져 왔습니다.


이것이 NODE.JS를 쉽게 설치하는 가장 좋은 방법입니다. 이것은 우분투 12.04, 13.04 및 14.04에도 해당됩니다.

노드 js 저장소 추가

[sudo] apt-get install python-software-properties
[sudo] apt-add-repository ppa:chris-lea/node.js
[sudo] apt-get update

node.js 설치

[sudo] apt-get install nodejs

이제 node.js 버전 확인

node -v

출력

v0.10.20

이 명령은 npm을 설치해야합니다.

npm install

NPM 버전 확인

npm -v

출력

1.4.3

어떤 이유로 npm이 설치되어 있지 않다면 다음을 실행 해보십시오.

[sudo] apt-get install npm

npm을 업데이트하려면 다음을 실행하십시오.

[sudo] npm install -g npm

You can use nvm to install nodejs. It allows you work with different versions without conflicts.


wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.19.0/install.sh | bash    

nvm install v0.10.33

just use nvm for node version control nvm


You can also compile it from source like this

git clone git://github.com/ry/node.git
cd node
./configure
make
sudo make install

Find detailed instructions here http://howtonode.org/how-to-install-nodejs


sudo apt-get install g++ curl libssl-dev apache2-utils
sudo apt-get install git-core
git clone git://github.com/ry/node.git
cd node
./configure
make
sudo make install

http://jstricks.com/install-node-js/


Follow the instructions given here at NodeSource which is dedicated to creating a sustainable ecosystem for Node.js

For Node.js >= 4.X

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

# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_4.x | bash -
apt-get install -y nodejs

Now you can simply Install with:

sudo apt-get install nodejs
sudo apt-get install npm

Make sure you have python and c preinstalled. If not perform:

sudo apt-get install python g++ make

I personally do it this way:

sudo apt-get install python g++ make
wget http://nodejs.org/dist/node-latest.tar.gz
tar xvfvz node-latest.tar.gz
cd node-v0.12.0
./configure
make
sudo make install

If you want to install particular version than download the version you want from nodejs site and execute the last tree steps.
I would strongly suggest not using the default nodejs package from the distro market because it would be probably outdated. (i.e. the current for the time of writing this in the ubuntu market is v0.10.25 which is too outdated compared to the latest (v0.12.0)).


Node.js is available as a snap package in all currently supported versions of Ubuntu. Specific to Node.js, developers can choose from one or more of the currently supported releases and get regular automatic updates directly from NodeSource. Node.js versions 6, 8, 9, 10, 11, 12 and 13 are currently available, with the Snap Store being updated within hours or minutes of a Node.js release.

Node can be installed with a single command, for example:

sudo snap install node --classic --channel 11/stable 

The node snap can be accessed by the command node, for example:

$ node -v  
v11.5.0

An up-to-date version of npm will installed as part of the node snap. npm should be run outside of the node repl, in your normal shell. After installing the node snap run the following command to enable npm update checking:

sudo chown -R $USER:$(id -gn $USER) /home/your-username/.config

Replace your-username in the above command with your own username. Then run npm -v to check if the version of npm is up-to-date. As an example I checked that npm was up-to-date, checked the version of an already installed package named yarn with the command npm list yarn and then updated the existing yarn package to the latest version with the command npm update yarn

Users can switch between versions of Node.js at any time without needing to involve additional tools like nvm (Node Version Manager), for example:

sudo snap refresh node --channel=11/stable

Users can test bleeding-edge versions of Node.js that can be installed from the latest edge channel which is currently tracking Node.js version 12 by switching with:

sudo snap switch node --edge

This approach is only recommended for those users who are willing to participate in testing and bug reporting upstream.

Node.js LTS Schedule

Release LTS Status  Codename    LTS Start       Maintenance Start Maintenance End
6.x     Active      Boron       2016-10-18      April 2018        April 2019
7.x     No LTS              
8.x     Active      Carbon      2017-10-31      April 2019        December 2019
9.x     No LTS              
10.x    Active      Dubnium     October 2018    April 2020        April 2021  
11.x    No LTS                                  2019-04-01        2019-06-30
12.x                            2019-10-22      2021-04-01        2022-04-01
13.x    No LTS                                  2020-04-20        2020-06-01

Here full description to create first program using express generator

Ubuntu's package manager

To install Node and npm via apt-get, run these commands:

sudo apt-get update  
sudo apt-get install nodejs  
sudo ln -s /usr/bin/nodejs /usr/bin/node  
sudo apt-get install npm  

Express application generator

$ npm install express-generator -g

Display the command options with the -h option:

$ express -h

  Usage: express [options] [dir]

  Options:

    -h, --help          output usage information
    -V, --version       output the version number
    -e, --ejs           add ejs engine support (defaults to jade)
        --hbs           add handlebars engine support
    -H, --hogan         add hogan.js engine support
    -c, --css <engine>  add stylesheet <engine> support (less|stylus|compass|sass) (defaults to plain css)
        --git           add .gitignore
    -f, --force         force on non-empty directory

For example, the following creates an Express app named myapp in the current working directory:

$ express myapp

   create : myapp
   create : myapp/package.json
   create : myapp/app.js
   create : myapp/public
   create : myapp/public/javascripts
   create : myapp/public/images
   create : myapp/routes
   create : myapp/routes/index.js
   create : myapp/routes/users.js
   create : myapp/public/stylesheets
   create : myapp/public/stylesheets/style.css
   create : myapp/views
   create : myapp/views/index.jade
   create : myapp/views/layout.jade
   create : myapp/views/error.jade
   create : myapp/bin
   create : myapp/bin/www

Then install dependencies:

$ cd myapp
$ npm install

run the app with this command:

$ DEBUG=myapp:* npm start

Then load http://localhost:3000/ in your browser to access the app.

The generated app has the following directory structure:

├── app.js
├── bin
│   └── www
├── package.json
├── public
│   ├── images
│   ├── javascripts
│   └── stylesheets
│       └── style.css
├── routes
│   ├── index.js
│   └── users.js
└── views
    ├── error.jade
    ├── index.jade
    └── layout.jade

7 directories, 9 files

Install Node.js on Ubuntu 12.10 or 14.04 LTS or 16.04.1 LTS

Please avoid to install Node.js with apt-get on Ubuntu. If you already installed Node.js with the built in package manager, please remove that. (sudo apt-get purge nodejs && sudo apt-get autoremove && sudo apt-get autoclean)

The installation process on Linux is the same as on OSX. With the provided script:

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

$ nvm list
$ nvm ls-remote
$ nvm install 6.4.0
$ nvm use 6.4.0
$ nvm alias default 6.4.0
$ node -v
$ npm install -g npm
$ npm -v

One more thing! Don’t forget to run the following command, which increases the amount of inotify watches.

$ echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

Hope this help you!

참고URL : https://stackoverflow.com/questions/16302436/install-node-js-on-ubuntu

반응형