Question

I have installed Ubuntu 14.04 in a VM.Installed nodejs using software center.

suman@ubuntu:~$ node --version
v0.10.26
suman@ubuntu:~$ npm --version
1.4.3

npm config below

suman@ubuntu:~$ npm config ls -l
; cli configs
long = true
registry = "https://registry.npmjs.org/"

; userconfig /home/suman/.npmrc
prefix = "/.node"

; default values
always-auth = false
bin-links = true
browser = null
ca = null
cache = "/home/suman/.npm"
cache-lock-retries = 10
cache-lock-stale = 60000
cache-lock-wait = 10000
cache-max = null
cache-min = 10
cert = null
color = true
depth = null
description = true
dev = false
editor = "vi"
email = ""
engine-strict = false
fetch-retries = 2
fetch-retry-factor = 10
fetch-retry-maxtimeout = 60000
fetch-retry-mintimeout = 10000
force = false
git = "git"
git-tag-version = true
global = false
globalconfig = "/usr/local/etc/npmrc"
globalignorefile = "/usr/local/etc/npmignore"
group = 1000
heading = "npm"
https-proxy = null
ignore-scripts = false
init-module = "/home/suman/.npm-init.js"
init.author.email = ""
init.author.name = ""
init.author.url = ""
init.license = "ISC"
json = false
key = null
link = false
local-address = undefined
loglevel = "http"
; long = false (overridden)
message = "%s"
node-version = "v0.10.26"
npat = false
onload-script = false
optional = true
parseable = false
; prefix = "/usr" (overridden)
production = false
proprietary-attribs = true
proxy = null
rebuild-bundle = true
registry = "https://registry.npmjs.org/"
rollback = true
save = false
save-bundle = false
save-dev = false
save-optional = false
searchexclude = null
searchopts = ""
searchsort = "name"
shell = "/bin/bash"
shrinkwrap = true
sign-git-tag = false
strict-ssl = true
tag = "latest"
tmp = "/home/suman/tmp"
umask = 18
unicode = true
unsafe-perm = true
usage = false
user = 0
user-agent = "node/v0.10.26 linux x64"
userconfig = "/home/suman/.npmrc"
username = ""
version = false
versions = false
viewer = "man"

I have installed grunt-cli, bower etc using npm install -g grunt-cli bower But I am not able to execute these as shell command.

suman

Était-ce utile?

La solution

Its best to avoid having to issue sudo when installing nodejs packages as node should never be run as root (same reasons as HTTPD is not run as root). Always install and run node and npm as yourself. To start over with a fresh install of nodejs and npm (below nodejs git gives you npm) on ubuntu (especially after issuing various sudo commands) :

remove or rename these dirs : (created by npm, typically owned by root if you used sudo)

sudo mv ~yourUnixId/.npm ~yourUnixId/ignore.npm
sudo mv ~yourUnixId/tmp  ~yourUnixId/ignore_tmp    
sudo mv ~yourUnixId/.npmrc  ~yourUnixId/ignore_.npmrc
sudo mv ~yourUnixId/.npm-init.js  ~yourUnixId/ignore_.npm-init.js

download source from : http://nodejs.org/download/

cd /path/to/downloaded/src/

./configure   --prefix=${HOME}/bin/nodejs
make
make install  #  will install into above prefix dir

jack up your PATH to find new executables

export PATH=${HOME}/bin/nodejs/bin:$PATH:.

this defines path to reach nodejs modules when issuing npm commands :

export NODE_PATH=${HOME}/bin/nodejs/lib/node_modules

going forward always issue npm install AS YOURSELF NOT sudo with the -g flag as

npm install someCoolModule -g

execute node as yourself :

node myNode.js

you should be all set now - enjoy

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top