Unable to install karma in Ubuntu - node.js

While trying to install karma in ubuntu using command
sudo npm install -g karma
i'm getting errors like
npm ERR! at Object.parse (native)
npm ERR! at RegClient.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-registry-client/lib/request.js:238:23)
npm ERR! at Request.self.callback (/usr/local/lib/node_modules/npm/node_modules/request/index.js:148:22)
npm ERR! at Request.EventEmitter.emit (events.js:98:17)
npm ERR! at Request.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/request/index.js:876:14)
npm ERR! at Request.EventEmitter.emit (events.js:117:20)
npm ERR! at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/request/index.js:827:12)
npm ERR! at IncomingMessage.EventEmitter.emit (events.js:117:20)
npm ERR! at _stream_readable.js:910:16
npm ERR! at process._tickCallback (node.js:415:13)
And a number of errors like
npm ERR! registry error parsing json
And it's not getting installed.Any help would be appreciated.My node.js version is v0.10.13

my npn install karma failed and
i resolved my problems with
sudo ln -s /usr/bin/nodejs /usr/bin/node
on ubuntu 13.10

I had a problem with Ubuntu 12.04 running without sudo, removing the -g option solved the problem installing it locally
npm install karma
npm install

I had the same issue, fixed by downloading the source code for 0.10.15 version. ./configure && make && sudo make install then sudo npm install -g karma and it works!

I have a similar problem installing the karma into the ubuntu inside vagrant. In my case, the install looks good, but don't work as expected.
$ sudo npm install --global karma
$ karma
No command 'karma' found, did you mean:
Command 'karm' from package 'ktimetracker' (main)
karma: command not found
But, looking in the installation output, I could find where the karma was really installed:
/usr/lib/node_modules/karma/bin/karma
If want to just type karma and run, just run:
$ sudo ln -s /usr/lib/node_modules/karma/bin/karma /usr/bin/karma & chmod +x /usr/bin/karma

If anyone needs to install nvm (in order to change node's version), and then Nicolas's instructions:
curl https://raw.github.com/creationix/nvm/master/install.sh | sh
source ~/.profile
nvm ls-remote
nvm install 0.10.15
which node
node --version
sudo npm install karma
node --version
./configure
make
sudo make install
sudo npm install -g karma

Related

Can't install any Node packages globally Ubuntu Digital Ocean

Tried everything. Tried all the steps below, didn't work so I nuked my droplet and rebuilt to start over and try again. I'm Using Ubuntu. First thing once I ssh into my droplet was install node and npm via:
https://nodejs.org/en/download/package-manager/
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
Then
npm -v
5.6.0
node -v
v8.11.3
Then I try to install a package globally. I tried electron and it failed so I began messing with the node modules folder as I was getting the permission error with the fix documented here:
https://askubuntu.com/questions/869168/node-modules-have-755-permissions-what-permissions-should-i-set-so-that-npm-don
No luck. So I tried the solution documented here:
NPM global install "cannot find module"
echo $NODE_PATH
/usr/lib/nodejs:/usr/lib/node_modules:/usr/share/javascript:/home/username/.npm-global/lib/node_modules
So that didn't work either. This is the error now when I try and install any package globally:
npm install -g electron
I get:
Error: Cannot find module '/root/.npm-global/lib/node_modules/nightmare/node_modules/electron/install.js'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Function.Module.runMain (module.js:693:10)
at startup (bootstrap_node.js:191:16)
at bootstrap_node.js:612:3
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! electron#1.8.7 postinstall: `node install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the electron#1.8.7 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2018-08-03T03_26_03_827Z-debug.log
This error for any package I try to install. Not sure what else to try. Don't want to wipe out the droplet and start over...
I also had this issue but after adding sudo at start the issue went away.
like:
sudo npm -g install nodemon

Angular CLI v6.0.8 won't install

I've installed NodeJS via PPA on Ubuntu 18.04. However when running sudo npm install -g #angular/cli I get the error at the bottom of this post.
I am using node v10.6.0 and npm v6.1.0. I have tried these commands, with no luck:
A) sudo npm install -g #angular/cli#latest
B) npm install -g #angular/cli (no sudo)
C) sudo npm install -g angular-cli --unsafe-perm=true
One thing I noticed was that in case C it actually installs and works when running as sudo. But it doesn't work as a regular user ("bash: ng: command not found").
I have checked my PATH env variable and have confirmed that the result of npm bin -g (/usb/bin) is indeed in my PATH for all users.
Any help would be very much appreciated.
me#laptop:~$ sudo npm install -g #angular/cli
[sudo] password for me:
/usr/bin/ng -> /usr/lib/node_modules/#angular/cli/bin/ng
> #angular/cli#6.0.8 postinstall /usr/lib/node_modules/#angular/cli
> node ./bin/ng-update-message.js
internal/modules/cjs/loader.js:583
throw err;
^
Error: Cannot find module '/usr/lib/node_modules/#angular/cli/bin/ng-update-message.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
at Function.Module._load (internal/modules/cjs/loader.js:507:25)
at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
at startup (internal/bootstrap/node.js:236:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:560:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! #angular/cli#6.0.8 postinstall: `node ./bin/ng-update-message.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the #angular/cli#6.0.8 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
FOUND IT! After much digging around I realized this was a permissions issue. A system-wide umask in the PAM module (Ubuntu) was set to create files and folders with more restrictive permissions than usual. This is what I did to get back to normal and get Angular CLI installed:
sudo vi /etc/pam.d/common-session
Then change this line: session optional pam_umask.so umask=077
To this: session optional pam_umask.so
Reboot, then: sudo npm install -g #angular/cli
Et Voilà!

Unable to upgrade npm from 1.4.28 to latest (2.2)

I'm using stable version of node on Ubuntu 14.04. (installed via PPA) When I was trying to upgrade some packages like yo, I got the error below:
npm ERR! notsup Unsupported
npm ERR! notsup Not compatible with your version of node/npm: yo#1.4.2
npm ERR! notsup Required: {"node":">=0.10.0","npm":">=2.1.0"}
npm ERR! notsup Actual: {"npm":"1.4.28","node":"0.10.35"}
npm ERR! System Linux 3.13.0-32-generic
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "update" "-g"
npm ERR! cwd /home/ekrem
npm ERR! node -v v0.10.35
npm ERR! npm -v 1.4.28
npm ERR! code ENOTSUP
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/ekrem/npm-debug.log
npm ERR! not ok code 0
When I hit (sudo) npm update -g npm, here's the result I got:
npm#2.1.3 /home/ekrem/.node/lib/node_modules/ionic/node_modules/npm
After hitting npm -v
1.4.28
I've also cleared all files under ~/.npm, cleared cache, reinstall components I needed but nothing changes. In addition;
➜ ~ which node
/usr/bin/node
➜ ~ which npm
/usr/bin/npm
➜ ~ less ~/.npmrc
prefix = ~/.node
I've checked similar issues on the net but there's nothing close to mine.
UPDATE:
I've removed nodejs; cleared files under ~/.node & ~/.npm (as #johns has suggested) installed using first method of the instructions here. Here are updated outputs:
➜ node -v
v0.10.35
➜ npm -v
1.4.28
➜ which node
/home/ekrem/local/bin/node
➜ which npm
/home/ekrem/local/bin/npm
➜ npm update -g npm
# returns nothing
➜ ~ npm config get prefix
/home/ekrem/.node
I was facing a similar issue and found this post. The way I got npm to work after several tries is to remove all the npm 'node_module' folders and delete any npm config files particularly the .npmrc file in your home directory.
Then I ran 'sudo apt-get purge nodejs'.
I went to the installer and reinstalled nodejs using the following:
'curl https://npmjs.org/install.sh | sh'
then ran:
sudo apt-get install nodejs
Finally I ran:
npm update -g npm
There were issues posted about a bug in that 'update' function, but it seemed to work for me and I got from 1.4 to 2.7.
I hope this saves someone some time.
This solution worked for me
navigate to C:\Program Files (x86)\nodejs with cmd.exe and then run the installation without -g:
npm install npm
In my case I had to do the following steps to go from npm#1.4.28 to npm#3.2.0 (currently the latest):
curl -L https://www.npmjs.org/install.sh | sudo sh
This line may trigger some errors like:
Error: EACCES, mkdir '/usr/lib/node_modules/npm'
If so, simply run:
sudo rm -rf /usr/lib/node_modules/npm (or the specified directory display in the error)
From there:
sudo npm install -g npm#3.0-latest
And now the
npm -v
successfully display a beautiful: 3.2.0
There are a lot of comments out there about "npm update -g" being broken and to not use it for now:
https://github.com/npm/npm/issues/6247
I'd trying resetting or reinstalling npm and then go from there - a fresh reinstall of npm should be relatively painless and fix things:
https://github.com/npm/npm/wiki/Troubleshooting#if-your-npm-is-broken
Similar answer to #ThinkBonobo, but all I had to do was run the update straight from npmjs.org. From a freshly provisioned instance:
$curl -sL https://deb.nodesource.com/setup | sudo bash -
$sudo apt-get install nodejs
$npm -v
1.4.28
$curl -L https://npmjs.org/install.sh | sudo sh
$npm -v
2.7.3
No other steps were requried.

NPM install giving error installing express

When I give command npm install express it throws following error. On ubuntu machine
gaurav#gaurav-Mini-Monster:~/TestScripts$ sudo npm install -g express
npm ERR! error installing express#3.3.3 Error: Unsupported
npm ERR! error installing express#3.3.3 at checkEngine (/usr/local/lib/node_modules/npm/lib/install.js:493:14)
npm ERR! error installing express#3.3.3 at Array.0 (/usr/local/lib/node_modules/npm/node_modules/slide/lib/bind-actor.js:15:8)
npm ERR! error installing express#3.3.3 at LOOP (/usr/local/lib/node_modules/npm/node_modules/slide/lib/chain.js:15:13)
npm ERR! error installing express#3.3.3 at chain (/usr/local/lib/node_modules/npm/node_modules/slide/lib/chain.js:20:4)
npm ERR! error installing express#3.3.3 at installOne_ (/usr/local/lib/node_modules/npm/lib/install.js:470:3)
npm ERR! error installing express#3.3.3 at installOne (/usr/local/lib/node_modules/npm/lib/install.js:411:3)
npm ERR! error installing express#3.3.3 at /usr/local/lib/node_modules/npm/lib/install.js:347:9
npm ERR! error installing express#3.3.3 at /usr/local/lib/node_modules/npm/node_modules/slide/lib/async-map.js:54:35
npm ERR! error installing express#3.3.3 at Array.forEach (native)
npm ERR! error installing express#3.3.3 at /usr/local/lib/node_modules/npm/node_modules/slide/lib/async-map.js:54:11
npm ERR! error rolling back express#3.3.3 Error: UNKNOWN, Unknown error '/usr/local/lib/node_modules/express'
npm ERR! Unsupported
npm ERR! Not compatible with your version of node/npm: connect#2.8.3
npm ERR! Required: {"node":">= 0.8.0"}
npm ERR! Actual: {"npm":"1.0.106","node":"0.5.11-pre"}
npm ERR!
npm ERR! System Linux 3.2.0-48-generic-pae
npm ERR! command "node" "/usr/local/bin/npm" "install" "-g" "express"
npm ERR! cwd /home/gaurav/TestScripts
npm ERR! node -v v0.5.11-pre
npm ERR! npm -v 1.0.106
npm ERR! code ENOTSUP
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/gaurav/TestScripts/npm-debug.log
npm not ok
I also tried
sudo npm install express
npm install -g express
sudo npm install -g express
Nothing works.
Node is so easy to install manually. I like doing it this way too because it's really easy to switch versions.
This is also great because you don't need to add some external package repository to apt, and you don't have to wait for those repositories to update when node releases a new version. You can get updates as soon as they're released.
# make a `~/.nodes/ folder
mkdir -p ~/.nodes && cd ~/.nodes
# download the binaries from nodejs.org
# in this case, here's the linux version
curl -O http://nodejs.org/dist/v0.10.12/node-v0.10.12-linux-x64.tar.gz
# extract
tar -xzf node-v0.10.12-linux-x64.tar.gz
# rename folder to 0.10.12
mv node-v0.10.12-linux-x64 0.10.12
# create a `current` symlink
ln -s 0.10.12 current
# prepend ~/.nodes/bin to your path
# you'll want to save this in ~/.bashrc or ~/.zshrc or something
export PATH="~/.nodes/current/bin:$PATH"
# cleanup
rm ~/.nodes/node-v0.10.12-linux-x64.tar.gz
The best part about this is you can repeat the pattern for any other version of node, change the current symlink at any time to switch which version you're running, and you're good to go
% node --version
v0.10.12
% npm --version
1.2.32
# switch versions to (e.g.) 0.10.5
% cd ~/.nodes && rm current && ln -s 0.10.5 current
% node --version
v0.10.5
% npm --version
1.2.18
Additional pointers when writing executable scripts
Make an executable file
% touch ~/somefile && chmod +x ~/someifle && nano ~/somefile
File contents
#!/usr/bin/env node
console.log(process.version);
Run it
% ./somefile
v0.10.12
You are running a much-too-old version of node and npm. You have node v0.5 which is very out of date. Upgrade to node v0.10 and things will work.
Modern node.js versions for Ubuntu are available via this PPA from Chris Lea
To install:
sudo apt-get install python-software-properties
sudo add-apt-repository --yes ppa:chris-lea/node.js
sudo apt-get install nodejs
UPDATE
It looks like your old version of node is installed at /usr/local/bin/node. The new version from the Chris Lea PPA will be at /usr/bin/node. So to verify all is well, do:
/usr/bin/npm --version #Should be approx 1.2
/usr/bin/node --version #should be approx v0.10
/usr/bin/npm install -g express
You should uninstall the local node, or fix your PATH:
export PATH=/usr/bin:$PATH

While installing Node.JS forever NPM package, it errors out on git:// address dependency

I get the following error while trying to install forever (sudo npm install forever -g):
npm info bundling for forever#0.8.2 [ 'git://github.com/bmeck/node-fork.git' ]
npm ERR! Doesn't exist: git://github.com/bmeck/node-fork.git
npm ERR! Error installing git://github.com/bmeck/node-fork.git
npm ERR! install failed Error: ENOENT, No such file or directory 'git://github.com/bmeck/node-fork.git'
npm info install failed rollback
I realized I didn't have git-core installed, so I apt-got it, and was able to clone from that git address. Is there something else I'm forgetting?
Found out I was running an older version of NPM (0.2.19) upgraded using: curl http://npmjs.org/install.sh | sudo sh
and sudo npm install forever -g worked

Resources