not able to run globally installed node modules - node.js

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

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

Related

npm install failing after clean install with Error: Cannot find module 'are-we-there-yet'

I attempted to update npm via different means (console and npm-windows-upgrade), ended up with multiple installations and decided to uninstall everything, clear the path and start over again.
After installing the newest lts version via the installer from https://nodejs.org/en/ npm and node versions are displayed correctly
node -v
v16.14.2
npm -v
8.5.0
Now running npm install results in the error
Error: Cannot find module 'are-we-there-yet'
Require stack:
npm ERR! - C:\Users\Kilian\git\FooBar\node_modules\npmlog\log.js
npm ERR! - C:\Users\Kilian\git\FooBar\node_modules\#mapbox\node-pre-gyp\lib\node-pre-gyp.js
npm ERR! - C:\Users\Kilian\git\FooBar\node_modules\#mapbox\node-pre-gyp\lib\main.js
npm ERR! - C:\Users\Kilian\git\FooBar\node_modules\#mapbox\node-pre-gyp\bin\node-pre-gyp
npm ERR! at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
...
code: 'MODULE_NOT_FOUND',
NodeJs installation directory: C:\Program Files\nodejs
Are-we-there-yet is present in the node_folder C:\Program Files\nodejs\node_modules\npm\node_modules\are-we-there-yet
npm prefix -g resolves to C:\Users\Kilian\AppData\Roaming\npm
C:\Program Files\nodejs\ is in the PATH and nothing other nodejs or npm related
PS C:\Users\Kilian\git\FooBar> npm config ls -l
; "default" config from default values
_auth = (protected)
access = null
all = false
allow-same-version = false
also = null
audit = true
audit-level = null
auth-type = "legacy"
before = null
bin-links = true
browser = null
ca = null
cache = "C:\\Users\\Kilian\\AppData\\Local\\npm-cache"
cache-max = null
cache-min = 0
cafile = null
call = ""
cert = null
ci-name = null
cidr = null
color = true
commit-hooks = true
depth = null
description = true
dev = false
diff = []
diff-dst-prefix = "b/"
diff-ignore-all-space = false
diff-name-only = false
diff-no-prefix = false
diff-src-prefix = "a/"
diff-text = false
diff-unified = 3
dry-run = false
editor = "notepad.exe"
engine-strict = false
fetch-retries = 2
fetch-retry-factor = 10
fetch-retry-maxtimeout = 60000
fetch-retry-mintimeout = 10000
fetch-timeout = 300000
force = false
foreground-scripts = false
format-package-lock = true
fund = true
git = "git"
git-tag-version = true
global = false
global-style = false
globalconfig = "C:\\Users\\Kilian\\AppData\\Roaming\\npm\\etc\\npmrc"
heading = "npm"
https-proxy = null
if-present = false
ignore-scripts = false
include = []
include-staged = false
include-workspace-root = false
init-author-email = ""
init-author-name = ""
init-author-url = ""
init-license = "ISC"
init-module = "C:\\Users\\Kilian\\.npm-init.js"
init-version = "1.0.0"
init.author.email = ""
init.author.name = ""
init.author.url = ""
init.license = "ISC"
init.module = "C:\\Users\\Kilian\\.npm-init.js"
init.version = "1.0.0"
json = false
key = null
legacy-bundling = false
legacy-peer-deps = false
link = false
local-address = null
location = "user"
lockfile-version = null
loglevel = "notice"
logs-max = 10
; long = false ; overridden by cli
maxsockets = 15
message = "%s"
metrics-registry = "https://registry.npmjs.org/"
node-options = null
node-version = "v16.14.2"
noproxy = [""]
npm-version = "8.5.0"
offline = false
omit = []
only = null
optional = null
otp = null
pack-destination = "."
package = []
package-lock = true
package-lock-only = false
parseable = false
prefer-offline = false
prefer-online = false
; prefix = "C:\\Program Files\\nodejs" ; overridden by builtin
preid = ""
production = null
progress = true
proxy = null
read-only = false
rebuild-bundle = true
registry = "https://registry.npmjs.org/"
save = true
save-bundle = false
save-dev = false
save-exact = false
save-optional = false
save-peer = false
save-prefix = "^"
save-prod = false
scope = ""
script-shell = null
searchexclude = ""
searchlimit = 20
searchopts = ""
searchstaleness = 900
shell = "C:\\WINDOWS\\system32\\cmd.exe"
shrinkwrap = true
sign-git-commit = false
sign-git-tag = false
sso-poll-frequency = 500
sso-type = "oauth"
strict-peer-deps = false
strict-ssl = true
tag = "latest"
tag-version-prefix = "v"
timing = false
tmp = "C:\\Users\\Kilian\\AppData\\Local\\Temp"
umask = 0
unicode = true
update-notifier = true
usage = false
user-agent = "npm/{npm-version} node/{node-version} {platform} {arch} workspaces/{workspaces} {ci}"
userconfig = "C:\\Users\\Kilian\\.npmrc"
version = false
versions = false
viewer = "browser"
which = null
workspace = []
workspaces = null
yes = null
; "builtin" config from C:\Program Files\nodejs\node_modules\npm\npmrc
prefix = "C:\\Users\\Kilian\\AppData\\Roaming\\npm"
; "user" config from C:\Users\Kilian\.npmrc
python = "C:\\Users\\Kilian\\.windows-build-tools\\python27\\python.exe"
; "cli" config from command line options
long = true
I am a bit of a loss on why npm does not find the correct module. Do I have to explicitly set a path to the nodejs directory are there config file conflicts left over from the previous install?
I would like to understand the culprit so it can be properly fixed and not cause issues with global installation of packages down the line.
Npm run in the console is actually the one installed with nodejs:
PS C:\Users\Kilian\git\FooBar> gcm npm
CommandType Name Version Source
----------- ---- ------- ------
Application npm.cmd 0.0.0.0 C:\Program Files\nodejs\npm.cmd
In my case the issue resolved itself after doing a simple npm install on a fresh initialized repo. I can not tell if this finally solved the issue or if it was something else but now it is working again.
That's good you managed to resolve it!
It could be possibly related to some cache issues or package-lock.json content, next time it happens you could try removing the lock file and/or cleaning npm cache.

How to fix npm installation issue?

I'm trying to install npm package
npm ERR! code EHOSTUNREACH
npm ERR! errno EHOSTUNREACH
npm ERR! request to https://registry.npmjs.org/express-session failed, reason: connect EHOSTUNREACH 104.16.23.35:443 - Local (192.0.108.1:52659)
I tried resetting npm configuration to the default values. I also tried installing with/out vpn, but still didn't work..
Here is the configuration:
; userconfig /Users/mac/.npmrc
access = null
allow-same-version = false
also = null
always-auth = false
audit = true
audit-level = "low"
auth-type = "legacy"
before = null
bin-links = true
browser = null
ca = null
cache = "/Users/mac/.npm"
cache-lock-retries = 10
cache-lock-stale = 60000
cache-lock-wait = 10000
cache-max = 0
cache-min = 10
cafile = "/Users/mac/Projects/NodeProjects/Bloggy/undefined"
cert = null
cidr = null
color = true
commit-hooks = true
depth = 0
description = true
dev = false
dry-run = false
editor = "vi"
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
global-style = false
globalconfig = "/usr/local/etc/npmrc"
globalignorefile = "/usr/local/etc/npmignore"
group = 20
ham-it-up = false
heading = "npm"
https-proxy = null
if-present = false
ignore-prepublish = false
ignore-scripts = false
init-author-email = ""
init-author-name = ""
init-author-url = ""
init-license = "ISC"
init-module = "/Users/mac/.npm-init.js"
init-version = "1.0.0"
json = false
key = null
legacy-bundling = false
link = false
local-address = undefined
loglevel = "notice"
logs-max = 10
long = false
maxsockets = 50
message = "%s"
node-options = null
node-version = "10.15.3"
noproxy = null
offline = false
onload-script = null
only = null
optional = true
otp = null
package-lock = true
package-lock-only = false
parseable = false
prefer-offline = false
prefer-online = false
prefix = "/usr/local"
preid = ""
production = false
progress = true
proxy = null
read-only = false
rebuild-bundle = true
registry = "https://registry.npmjs.org/"
rollback = true
save = true
save-bundle = false
save-dev = false
save-exact = false
save-optional = false
save-prefix = "^"
save-prod = false
scope = ""
script-shell = null
scripts-prepend-node-path = "warn-only"
searchexclude = null
searchlimit = 20
searchopts = ""
searchstaleness = 900
send-metrics = false
shell = "/bin/bash"
shrinkwrap = true
sign-git-commit = false
sign-git-tag = false
sso-poll-frequency = 500
sso-type = "oauth"
strict-ssl = true
tag = "latest"
tag-version-prefix = "v"
timing = false
tmp = "/var/folders/qc/f1s84bcj5y10v57pvz0s4st40000gn/T"
umask = 18
unicode = true
unsafe-perm = true
update-notifier = true
usage = false
user = 0
userconfig = "/Users/mac/.npmrc"
version = false
versions = false
viewer = "man"
I set these values while trying to fix this problem, but still doesn't work. I may need to say that npm was working perfectly before..
To answer your question, you have a problem with connecting registry.npmjs.org.
Try firing below commands(considering you are using windows).
ping registry.npmjs.org
traceroute -n registry.npmjs.org
if the first command returns "Destination Host Unreachable", you are behind the firewall and its blocking you reaching to the server.
Further you can check your .npmrc entries or npm config ls
I had the same problem on ubuntu (wsl).
Try these:
$ ping registry.npmjs.org
$ npm view npm version
If the ping is not successful, there are multiple options:
check your connection
check your firewall
check your proxy
For me it was the proxy and I had to disable the option Detect automaticaly the settings

SSD vs HDD as a performance factor in npm configuration: where to put .npm cache and node_modules directories to achieve best performance?

Considering a dual-drive laptop with a 256GB SSD and 1TB HDD, where should one put their .npm cache and node_modules directories to achieve best performance?
Any other advice warmly welcome.
For your information:
My whole /home/username partition is on the HDD.
I use nvm
And here's the whole npm config (as extracted with npm config ls -l command):
; cli configs
long = true
metrics-registry = "https://registry.npmjs.org/"
scope = ""
user-agent = "npm/6.9.0 node/v10.15.3 linux x64"
; default values
access = null
allow-same-version = false
also = null
always-auth = false
audit = true
audit-level = "low"
auth-type = "legacy"
before = null
bin-links = true
browser = null
ca = null
cache = "/home/username/.npm"
cache-lock-retries = 10
cache-lock-stale = 60000
cache-lock-wait = 10000
cache-max = null
cache-min = 10
cafile = undefined
cert = null
cidr = null
color = true
commit-hooks = true
depth = null
description = true
dev = false
dry-run = false
editor = "vi"
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
global-style = false
globalconfig = "/home/username/.nvm/versions/node/v10.15.3/etc/npmrc"
globalignorefile = "/home/username/.nvm/versions/node/v10.15.3/etc/npmignore"
group = 1001
ham-it-up = false
heading = "npm"
https-proxy = null
if-present = false
ignore-prepublish = false
ignore-scripts = false
init-author-email = ""
init-author-name = ""
init-author-url = ""
init-license = "ISC"
init-module = "/home/username/.npm-init.js"
init-version = "1.0.0"
json = false
key = null
legacy-bundling = false
link = false
local-address = undefined
loglevel = "notice"
logs-max = 10
; long = false (overridden)
maxsockets = 50
message = "%s"
; metrics-registry = null (overridden)
node-options = null
node-version = "10.15.3"
noproxy = null
offline = false
onload-script = null
only = null
optional = true
otp = null
package-lock = true
package-lock-only = false
parseable = false
prefer-offline = false
prefer-online = false
prefix = "/home/username/.nvm/versions/node/v10.15.3"
preid = ""
production = false
progress = true
proxy = null
read-only = false
rebuild-bundle = true
registry = "https://registry.npmjs.org/"
rollback = true
save = true
save-bundle = false
save-dev = false
save-exact = false
save-optional = false
save-prefix = "^"
save-prod = false
scope = ""
script-shell = null
scripts-prepend-node-path = "warn-only"
searchexclude = null
searchlimit = 20
searchopts = ""
searchstaleness = 900
send-metrics = false
shell = "/bin/bash"
shrinkwrap = true
sign-git-commit = false
sign-git-tag = false
sso-poll-frequency = 500
sso-type = "oauth"
strict-ssl = true
tag = "latest"
tag-version-prefix = "v"
timing = false
tmp = "/tmp"
umask = 18
unicode = true
unsafe-perm = true
update-notifier = true
usage = false
user = 1001
; user-agent = "npm/{npm-version} node/{node-version} {platform} {arch}" (overridden)
userconfig = "/home/username/.npmrc"
version = false
versions = false
viewer = "man"
Well, SSD drives have better performance, easy answer would be: put everything on SSD.
If you are constrained by disk space, then I would move the .npm cached folder to SSD, since it is shared by every yarn/npm install.

S3cmd configuration not working properly ERROR: S3 error: None

I am trying to install s3cmd in centos with below configuration. But when i try to list down all buckets it give error s3cmd ls
ERROR: S3 error: None
I have checked python version is 2.6.6 and s3cmd version 1.5.1.2
http://s3tools.org/kb/item14.htm
http://s3tools.org/kb/item1.htm
[default]
access_key = ACCESS_KEY
access_token =
add_encoding_exts =
add_headers =
bucket_location = US
ca_certs_file =
cache_file =
check_ssl_certificate = True
cloudfront_host = cloudfront.amazonaws.com
default_mime_type = binary/octet-stream
delay_updates = False
delete_after = False
delete_after_fetch = False
delete_removed = False
dry_run = False
enable_multipart = True
encoding = UTF-8
encrypt = False
expiry_date =
expiry_days =
expiry_prefix =
follow_symlinks = False
force = False
get_continue = False
gpg_command = /usr/bin/gpg
gpg_decrypt = %(gpg_command)s -d --verbose --no-use-agent --batch --yes --passphrase-fd %(passphrase_fd)s -o %(output_file)s %(input_file)s
gpg_encrypt = %(gpg_command)s -c --verbose --no-use-agent --batch --yes --passphrase-fd %(passphrase_fd)s -o %(output_file)s %(input_file)s
gpg_passphrase = secret
guess_mime_type = True
host_base = vault.ecloud.co.uk
host_bucket = %(bucket)s.vault.ecloud.co.uk
human_readable_sizes = False
ignore_failed_copy = False
invalidate_default_index_on_cf = False
invalidate_default_index_root_on_cf = True
invalidate_on_cf = False
list_md5 = False
log_target_prefix =
max_delete = -1
mime_type =
multipart_chunk_size_mb = 15
preserve_attrs = True
progress_meter = True
proxy_host =
proxy_port = 0
put_continue = False
recursive = False
recv_chunk = 4096
reduced_redundancy = False
restore_days = 1
secret_key = SECRET_KEY
send_chunk = 4096
server_side_encryption = False
signature_v2 = False
simpledb_host = sdb.amazonaws.com
skip_existing = False
socket_timeout = 300
urlencoding_mode = normal
use_https = True
use_mime_magic = True
verbosity = WARNING
website_endpoint = http://%(bucket)s.s3-website-%(location)s.vault.ecloud.co.uk/
website_error =
website_index = index.html
After few search i found solution, it was due to RequestTimeTooSkewed.
Through this command i was able to debug this s3cmd --configuration --debug
Error><Code>RequestTimeTooSkewed</Code></Error>
You can fix RequestTimeTooSkewed with these commands
apt-get install ntp
or
yum install ntp
Configure NTP to use amazon servers , like so :
vim /etc/ntp.conf
service ntpd restart
For detail you can follow this link http://www.emind.co/how-to/how-to-fix-amazon-s3-requesttimetooskewed

`npm install` installs all dependencies of my project over the network, even if they are already installed or available from cache

whenever I run npm install in my project directory, npm fetches and installs all dependencies even if they're already installed in node_modules. Npm does not install from my cache in ~/.npm/, even though there are already an extremely large number of packages in my cache.
Here is my npm config settings from npm config ls -l:
; cli configs
long = true
registry = "https://registry.npmjs.org/"
; userconfig /Users/jay/.npmrc
username = "jayhendren"
; globalconfig /Users/jay/local/nodejs/etc/npmrc
global = true
globalconfig = "/Users/jay/local/nodejs/etc/npmrc"
globalignorefile = "/Users/jay/local/nodejs/etc/npmignore"
prefix = "/Users/jay/local/nodejs"
; default values
always-auth = false
bin-links = true
browser = null
ca = null
cache = "/Users/jay/.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 = "/usr/bin/vim"
; email = "" (overridden)
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
group = 20
heading = "npm"
https-proxy = null
ignore-scripts = false
init-module = "/Users/jay/.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.25"
npat = false
onload-script = false
optional = true
parseable = false
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/zsh"
shrinkwrap = true
sign-git-tag = false
strict-ssl = true
tag = "latest"
tmp = "/var/folders/sq/ls98jmdd09l__xwpxq3qqmpw0000gn/T/"
umask = 18
unicode = true
unsafe-perm = true
usage = false
user = "nobody"
user-agent = "node/v0.10.25 darwin x64"
userconfig = "/Users/jay/.npmrc"
; username = "" (overridden)
version = false
versions = false
viewer = "man"
Does anybody know why npm insists on fetching new packages over and over and over again?
To install the packages from the cache force, you can use the following way:
$ npm --cache-min 9999999 install
See also:
https://addyosmani.com/blog/using-npm-offline/
Use a combination of flags to emulate skip-installed
global = false
link = true
foo
+-- node_modules
+-- blerg (1.2.5) <---[A]
+-- bar (1.2.3) <---[B]
| `-- node_modules
| +-- baz (2.0.2) <---[C]
| | `-- node_modules
| | `-- quux (3.2.0)
| `-- asdf (2.3.4)
`-- baz (1.2.3) <---[D]
`-- node_modules
`-- quux (3.2.0) <---[E]
References
npm 1.0:link
npm 1.0:Global vs Local installation
npm-folders
node.js global objects
I ran "npm prune" inside my project, to remove unnecessary packages (i.e., that were not dependencies, and give you that irritating "extraneous" error message). One side effect seemed to be to remove the kind of redundant package you are talking about. For example, gulp requires the gulp-util package. Since that was already at the "top" level, it was removed from gulp's own node-modules.

Resources