Unitech / pm2

Node.js Production Process Manager with a built-in Load Balancer.
https://pm2.keymetrics.io/docs/usage/quick-start/
Other
41.33k stars 2.61k forks source link

cannot install on ubuntu #188

Closed leabdalla closed 10 years ago

leabdalla commented 10 years ago

in OSX install runs fine, but not in DigitalOcean Ubuntu via ssh (as root)

root@bdev:~/local/bin# npm install -g pm2
npm http GET https://registry.npmjs.org/pm2
npm http 304 https://registry.npmjs.org/pm2
npm http GET https://registry.npmjs.org/cli-table/0.2.0
npm http GET https://registry.npmjs.org/pm2-multimeter/0.1.2
npm http GET https://registry.npmjs.org/usage/0.3.9
npm http GET https://registry.npmjs.org/axon-rpc/0.0.2
npm http GET https://registry.npmjs.org/watch/0.8.0
npm http GET https://registry.npmjs.org/axon/1.0.0
npm http GET https://registry.npmjs.org/cron/1.0.1
npm http GET https://registry.npmjs.org/coffee-script
npm http GET https://registry.npmjs.org/colors/0.6.2
npm http GET https://registry.npmjs.org/eventemitter2/0.4.13
npm http GET https://registry.npmjs.org/debug
npm http GET https://registry.npmjs.org/commander/2.0.0
npm http 304 https://registry.npmjs.org/usage/0.3.9
npm http 304 https://registry.npmjs.org/axon-rpc/0.0.2
npm http 304 https://registry.npmjs.org/cli-table/0.2.0
npm http 304 https://registry.npmjs.org/watch/0.8.0
npm http 304 https://registry.npmjs.org/axon/1.0.0
npm http 304 https://registry.npmjs.org/cron/1.0.1
npm http 304 https://registry.npmjs.org/coffee-script
npm http 304 https://registry.npmjs.org/colors/0.6.2
npm http 304 https://registry.npmjs.org/pm2-multimeter/0.1.2
npm http 304 https://registry.npmjs.org/debug
npm http 304 https://registry.npmjs.org/eventemitter2/0.4.13
npm http 304 https://registry.npmjs.org/commander/2.0.0
npm http GET https://registry.npmjs.org/commander/1.0.5
npm http GET https://registry.npmjs.org/charm
npm http GET https://registry.npmjs.org/colors/0.3.0
npm http GET https://registry.npmjs.org/bindings
npm http GET https://registry.npmjs.org/configurable/0.0.1
npm http GET https://registry.npmjs.org/escape-regexp/0.0.1
npm http 304 https://registry.npmjs.org/commander/1.0.5
npm http 304 https://registry.npmjs.org/charm
npm http 304 https://registry.npmjs.org/bindings
npm http 304 https://registry.npmjs.org/colors/0.3.0
npm http 304 https://registry.npmjs.org/escape-regexp/0.0.1
npm http 304 https://registry.npmjs.org/configurable/0.0.1

> usage@0.3.9 install /root/local/lib/node_modules/pm2/node_modules/usage
> node-gyp rebuild

sh: 1: node-gyp: Permission denied
npm http GET https://registry.npmjs.org/keypress
npm ERR! Error: ENOENT, chown '/root/local/lib/node_modules/pm2/node_modules/axon/node_modules/escape-regexp/Makefile'
npm ERR! If you need help, you may report this log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <npm-@googlegroups.com>

npm ERR! System Linux 3.2.0-24-virtual
npm ERR! command "node" "/root/local/bin/npm" "install" "-g" "pm2"
npm ERR! cwd /root/local/bin
npm ERR! node -v v0.10.22
npm ERR! npm -v 1.3.15
npm ERR! path /root/local/lib/node_modules/pm2/node_modules/axon/node_modules/escape-regexp/Makefile
npm ERR! fstream_path /root/local/lib/node_modules/pm2/node_modules/axon/node_modules/escape-regexp/Makefile
npm ERR! fstream_type File
npm ERR! fstream_class FileWriter
npm ERR! fstream_finish_call chown
npm ERR! code ENOENT
npm ERR! errno 34
npm ERR! fstream_stack /root/local/lib/node_modules/npm/node_modules/fstream/lib/writer.js:305:19
npm ERR! fstream_stack /root/local/lib/node_modules/npm/node_modules/graceful-fs/polyfills.js:133:7
npm ERR! fstream_stack Object.oncomplete (fs.js:107:15)
npm ERR! Error: ENOENT, lstat '/root/local/lib/node_modules/pm2/node_modules/axon/node_modules/configurable/History.md'
npm ERR! If you need help, you may report this log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <npm-@googlegroups.com>

npm ERR! System Linux 3.2.0-24-virtual
npm ERR! command "node" "/root/local/bin/npm" "install" "-g" "pm2"
npm ERR! cwd /root/local/bin
npm ERR! node -v v0.10.22
npm ERR! npm -v 1.3.15
npm ERR! path /root/local/lib/node_modules/pm2/node_modules/axon/node_modules/configurable/History.md
npm ERR! fstream_path /root/local/lib/node_modules/pm2/node_modules/axon/node_modules/configurable/History.md
npm ERR! fstream_type File
npm ERR! fstream_class FileWriter
npm ERR! code ENOENT
npm ERR! errno 34
npm ERR! fstream_stack /root/local/lib/node_modules/npm/node_modules/fstream/lib/writer.js:284:26
npm ERR! fstream_stack Object.oncomplete (fs.js:107:15)
npm ERR! usage@0.3.9 install: `node-gyp rebuild`
npm ERR! Exit status 127
npm ERR!
npm ERR! Failed at the usage@0.3.9 install script.
npm ERR! This is most likely a problem with the usage package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls usage
npm ERR! There is likely additional logging output above.

npm ERR! System Linux 3.2.0-24-virtual
npm ERR! command "node" "/root/local/bin/npm" "install" "-g" "pm2"
npm ERR! cwd /root/local/bin
npm ERR! node -v v0.10.22
npm ERR! npm -v 1.3.15
npm ERR! code ELIFECYCLE
npm http 304 https://registry.npmjs.org/keypress
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     /root/local/bin/npm-debug.log
npm ERR! not ok code 0
root@bdev:~/local/bin#
chrisspiegl commented 10 years ago

I see the same error currently. But for now it seems that the problem is with the package "usage@0.3.9" hope to find a fix soon.

bretcope commented 10 years ago

PM2 Has been using the same (current) version of that package for a while, so I don't think that's the problem. The error message to me looks like you might not have node-gyp installed correctly.

How did you install node on Ubuntu? Did you follow the instructions Node.js provides for Ubuntu?

Specifically, make sure you have python, g++, and make installed:

sudo apt-get install -y python-software-properties python g++ make

If you installed node from apt-get, make sure you didn't install it from the outdated default repository. If you didn't install via apt-get, you may also need to install node-gyp itself.

chrisspiegl commented 10 years ago

Using Node on Ubuntu with NVM works ok now. I have tested this with Python 2.7. Here are two ways to run this:

Normal user (e.g. node)

adduser node
su node

NVM: INSTALL VIA https://github.com/creationix/nvm NVM: INSTALL NODE VERSION

npm install -g pm2

Fix that works with the root user

Installed NVM as root and installed node version is v0.10.22. If you are running with the root user, one fix is to install pm2 into a directory and move it to the global repo:

cd ~/
npm install pm2
mv node_modules/pm2 ~/.nvm/v0.10.22/node_modules/pm2
ln -s ~/.nvm/v0.10.22/node_modules/pm2/bin/pm2 ~/.nvm/v0.10.22/bin/pm2
bretcope commented 10 years ago

@cspiegl it doesn't sound like there is a "fix" here besides you need to be running the right version of node and have node-gyp and its dependencies installed. That's why I was asking what process you used to install node. If you followed the instructions I linked to on nodejs.org, it should install fine without nvm (I install from scratch on Ubuntu fairly regularly without problem).

chrisspiegl commented 10 years ago

The problem I found mainly was that I installed from scratch on node and wanted to run as root on my development machine. And that did not work if I used npm install pm2 -g. Than I did the above steps and both worked.

bretcope commented 10 years ago

@cspiegl Interesting. I just tried npm install pm2 -g as root and it succeeded, and I can run pm2 as root just fine.

If you're solution works for you, I guess that's what matters. This doesn't sound like a common use case to me, anyway.

chrisspiegl commented 10 years ago

I found it weird that it did not work. But now it works. I am happy. But I plan on using a node user anyways. So that problem will likely never arise again for me.

Just hope this helps someone someday ;-).

Unitech commented 10 years ago

thanks for explanations

iamgp commented 10 years ago

This isn't fixed. Still a problem for me! Neither "fix" fixes this.

ottes commented 10 years ago

Got the same under latest ubuntu, with latest node, npm and node-gyp

> usage@0.3.9 install /usr/local/lib/node_modules/pm2/node_modules/usage
> node-gyp rebuild

gyp WARN EACCES user "root" does not have permission to access the dev dir "/root/.node-gyp/0.10.26"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/lib/node_modules/pm2/node_modules/usage/.node-gyp"
gyp http GET http://nodejs.org/dist/v0.10.26/node-v0.10.26.tar.gz
gyp http 200 http://nodejs.org/dist/v0.10.26/node-v0.10.26.tar.gz
Traceback (most recent call last):
  File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py", line 18, in <module>
    sys.exit(gyp.script_main())
AttributeError: 'module' object has no attribute 'script_main'
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:337:16)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:797:12)
gyp ERR! System Linux 3.11.0-18-generic
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/local/lib/node_modules/pm2/node_modules/usage
gyp ERR! node -v v0.10.26
gyp ERR! node-gyp -v v0.12.2
gyp ERR! not ok 
npm http 304 https://registry.npmjs.org/configurable/0.0.1
npm http 304 https://registry.npmjs.org/charm
npm http 304 https://registry.npmjs.org/escape-regexp/0.0.1
npm http 304 https://registry.npmjs.org/keypress
npm http 304 https://registry.npmjs.org/mkdirp
npm ERR! usage@0.3.9 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the usage@0.3.9 install script.
npm ERR! This is most likely a problem with the usage package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls usage
npm ERR! There is likely additional logging output above.

npm ERR! System Linux 3.11.0-18-generic
npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "pm2"
npm ERR! cwd /home/fragger
npm ERR! node -v v0.10.26
npm ERR! npm -v 1.4.3
npm ERR! code ELIFECYCLE
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /home/fragger/npm-debug.log
npm ERR! not ok code 0
pward123 commented 10 years ago

Ran into this same problem on a new digital ocean droplet (Ubuntu 13.10 x64). Fixed it by switching to node v0.10.24 to do the install. So far (fingers crossed) switching back to v0.10.26 after installing seems to work.

Prinzhorn commented 10 years ago

Same here. I can't install pm2 on DigitalOcean 14.04 x64 and it also doesn't work on my 13.10 dev machine. I installed node using nvm and I want to keep it that way.

steve-jansen commented 10 years ago

Thanks to a workaround posted in node-gyp #363, I was able to resolve this issue when installing pm2 on CentOS 6.5 with python 2.6.6 already installed.

My basic steps:

# install node and npm ...
rm -rf $(dirname `python -c 'import gyp; print gyp.__file__'`)
npm install -g node-gyp
npm install -g pm2
gen4sp commented 10 years ago

! solution for mac go to ~/.npm dir and remove all pm2 packages (about 4 units)

zot24 commented 9 years ago

@gen4sp :+1:

soyuka commented 9 years ago

npm cache clear -f does exactly this

calvintwr commented 9 years ago

using: npm cache clear -f

and npm install pm2 -g --unsafe-perm

worked for me.

paulovieira commented 9 years ago

Same here. Using Ubuntu 14.04.1. I had the errors below. The commands given above solved the problem:

npm cache clear -f
npm install pm2 -g --unsafe-perm

The errors were

pedro@clima:~$ sudo npm install -g pm2
/
> pm2@0.11.1 preinstall /usr/lib/node_modules/pm2
> bash ./scripts/preinstall.sh

##### PM2 INSTALLATION
#
#
# As you run PM2 as root, to update PM2 automatically
# you must add the --unsafe-perm flag.
#
#       $  npm install pm2 -g --unsafe-perm
#
# Else run the installation as a non root user
#
#
#
######

npm ERR! pm2@0.11.1 preinstall: `bash ./scripts/preinstall.sh`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the pm2@0.11.1 preinstall script.
npm ERR! This is most likely a problem with the pm2 package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     bash ./scripts/preinstall.sh
npm ERR! You can get their info via:
npm ERR!     npm owner ls pm2
npm ERR! There is likely additional logging output above.
npm ERR! System Linux 3.13.0-32-generic
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install" "-g" "pm2"
npm ERR! cwd /home/pedro/node
npm ERR! node -v v0.10.33
npm ERR! npm -v 1.4.28
npm ERR! code ELIFECYCLE
npm ERR! not ok code 0
cheanizer commented 8 years ago

I just install at digital ocean droplet with ubuntu 14.04 node v0.10.25 and 1.3.10 but when i type pm2 start server.js. the console just close the command. like nothing happen. anyone have a solution?