Can't remove Gatsby NPM package on MacOS - macos

I'm having some issues getting Gatsby working. I want to remove my previous installation and start fresh.
Running npm list -g --depth 0 reveals:
/usr/local/lib
├── gatsby-cli#2.12.68
├── grunt-cli#1.3.2
└── npm#6.4.1
When I run npm uninstall --save -g gatsby-cli#2.12.68 the output is up to date in 0.031s - yet the Gatsby NPM package is still there.
Is there something I'm doing wrong here? Any help would be appreciated :)

Related

bash: pm2: command not found

I can't run pm2 on ubuntu box.
I'm not sure what's the problem.
The pm2 is installed globally.
npm list -g --depth=0
/opt/nodejs/lib
├── forever#0.15.3
├── node-gyp#3.4.0
├── npm#2.15.9
├── pm2#2.1.5
├── userdown#0.2.1
└── wait-for-mongo#0.2.0
But I still get
pm2
-bash: pm2: command not found
if I run other app
userdown
Starting Script is not provided
versions
node v4.5.0
npm v2.15.9
log from installation:
sudo npm install pm2 -g
npm WARN optional dep failed, continuing fsevents#1.0.15
/opt/nodejs/bin/pm2 -> /opt/nodejs/lib/node_modules/pm2/bin/pm2
/opt/nodejs/bin/rundev -> /opt/nodejs/lib/node_modules/pm2/bin/rundev
/opt/nodejs/bin/pm2-dev -> /opt/nodejs/lib/node_modules/pm2/bin/pm2-dev
/opt/nodejs/bin/pm2-docker -> /opt/nodejs/lib/node_modules/pm2/bin/pm2-docker
pm2#2.1.5 /opt/nodejs/lib/node_modules/pm2
├── gkt#1.0.0
├── eventemitter2#1.0.5
├── semver#5.3.0
├── async#1.5.2
├── fclone#1.0.10
├── pidusage#1.1.0
├── vizion#0.2.13
├── commander#2.9.0 (graceful-readlink#1.0.1)
├── debug#2.3.0 (ms#0.7.2)
├── pm2-axon-rpc#0.4.5 (fclone#1.0.8)
├── pm2-deploy#0.3.3 (tv4#1.2.7)
├── pm2-multimeter#0.1.2 (charm#0.1.2)
├── chalk#1.1.3 (escape-string-regexp#1.0.5, ansi-styles#2.2.1, supports-color#2.0.0, strip-ansi#3.0.1, has-ansi#2.0.0)
├── cli-table#0.3.1 (colors#1.0.3)
├── mkdirp#0.5.1 (minimist#0.0.8)
├── source-map-support#0.4.6 (source-map#0.5.6)
├── nssocket#0.6.0 (eventemitter2#0.4.14, lazy#1.0.11)
├── pmx#0.6.8 (json-stringify-safe#5.0.1)
├── pm2-axon#3.0.2 (amp-message#0.1.2, escape-regexp#0.0.1, amp#0.3.1, debug#2.2.0)
├── cron#1.1.1 (moment-timezone#0.5.9)
├── yamljs#0.2.8 (glob#7.1.1, argparse#1.0.9)
├── chokidar#1.6.1 (path-is-absolute#1.0.1, async-each#1.0.1, inherits#2.0.3, glob-parent#2.0.0, is-glob#2.0.1, is-binary-path#1.0.1, readdirp#2.1.0, anymatch#1.3.0)
├── shelljs#0.7.5 (interpret#1.0.1, glob#7.1.1, rechoir#0.6.2)
└── moment#2.17.0
kamil#vps2:~$ pm2
-bash: pm2: command not found
ubuntu version:
uname -a
Linux vps2 2.6.32-042stab111.11 #1 SMP Tue Sep 1 18:19:12 MSK 2015 x86_64 x86_64 x86_64 GNU/Linux
Ok got answer myself.
I check what happens for
whereis pm2
pm2: /opt/nodejs/bin/pm2
then I checked
whereis userdown
userdown: /usr/bin/userdown /usr/bin/X11/userdown /opt/nodejs/bin/userdown
hmm in /usr/bin....
So I did
sudo ln -s /opt/nodejs/bin/pm2 /usr/bin/pm2
and it works :)
The problem is that you are running NPM as sudo, so you will only be able to access it using:
sudo pm2 start server.js
Install without sudo, you may even install without the -gflag and call it directly from node_modules directory. This may be useful if you do not have root (admin) privileges in the machine you're working on.
npm install pm2
./node_modules/.bin/pm2 start server.js
Follow the proper nodejs isntallation, npm permission fixes and npm global packages tweaks:
# https://gist.github.com/servercharlie/9a7e0d0e1645b4c6fbfe5de566fcf1ca
Your script needs to do some thing that requires root privilege? (ie: you're getting an error on using port 80)
[wrong] - trying to run w/ sudo
[correct] - login as root "sudo su" then do pm2 start app.js --name "whatever" --watch
that does it, no need to configure any bashrc or profile files.
extra: worried about your app doing crazy shit? (ie, since it's executed as root, the script can use nodejs's exec and do some crazy stuff.)
hence. do this: do the root-stuff first with your script, then lower your privilege after some timeout:
// i use port 80 first.. at this point the script's uid is ROOT.
app.listen(80);
// after 2 seconds we switch to uid AZUREUSER, which obviously isn't root anymore.
setTimeout(function(){
process.setuid("azureuser");
}, 2000);
In my scenario I wrote a shell script that was triggered by jenkins build and
I fixed using following link
https://github.com/Unitech/pm2-deploy/issues/41

'npm-windows-upgrade' is not recognized as an internal or external command

I ran
$ npm install --global --production npm-windows-upgrade
and it returned this positive looking feedback
├── cli-spinner#0.2.5
├── commander#2.9.0 (graceful-readlink#1.0.1)
├── chalk#1.1.3 (ansi-styles#2.2.1, escape-string-regexp#1.0.5, supports-color#2
.0.0, strip-ansi#3.0.1, has-ansi#2.0.0)
├── promise#7.1.1 (asap#2.0.4)
├── inquirer#1.0.3 (ansi-escapes#1.4.0, mute-stream#0.0.6, through#2.3.8, cli-wi
dth#2.1.0, strip-ansi#3.0.1, figures#1.7.0, pinkie-promise#2.0.1, run-async#2.2.
0, string-width#1.0.1, cli-cursor#1.0.2, rx#4.1.0, lodash#4.14.0)
├── babel-polyfill#6.9.1 (regenerator-runtime#0.9.5, babel-runtime#6.9.2, core-j
s#2.4.1)
├── regenerator-runtime-only#0.8.38 (promise#6.1.0, es6-symbol#2.0.1)
└── prompt#1.0.0 (revalidator#0.1.8, pkginfo#0.4.0, colors#1.1.2, read#1.0.7, ut
ile#0.3.0, winston#2.1.1)
But when I run
$ npm-windows-upgrade
I get
'$ npm-windows-upgrade' is not recognized as an internal or external
command
I was following the directions here. Any idea what's going on? I've been googling it for a while and not getting much more than those basic instructions.
UPDATE
Realized the issue was with everything I was trying to install globally. I thought the other packages I was trying to run worked but they did not. For example $ webpack returns the same error after installing it gloablly.
BACKGROUND
I'm running windows and had previously installed npm. When that started giving me all sorts of bugs I upgraded to npm3. I belive it was just
$ npm install npm3 -g
and then running all my commands starting with npm3, for example
$ npm3 install webpack --save
Today the same command gave me
'npm3' is not recognized as an internal or external command
So I tried to reinstall it with regular npm which gave me "'npm' ins not recognized..."
I was able to get npm working again after following these lovely instructions, but cannot figure out how to get back to version 3.
Also $ npm -v right now is 2.15.1
To answer my own question.
The problem was my path settings. Npm itself was working, but for some reason the location where it was installing global node modules was in different directory. I saw this when I ran
$ npm install npm-windows-upgrade -g
The first few lines it prints when you install show where it is being installed.
I noticed it was being installed in
C:\Users\(my_username)\AppData\Roaming\npm\nodemodules\npm-windows-upgrade
even though I had just fixed npm by pointing it to
C:\ProgramFiles\npm
so I changed that to the npm location it was actually using to
C:\Users\(my_username)\AppData\Roaming\npm
restarted my computer and it worked.
Here again are instructions to change your path variables.

Laravel Forge kills the deploy script

The Forge server has been linked to a GitLab repository. So every time I push my new commits to my master branch Gitlab triggers Forge's Deployment url.
The problem seems like my deploy script are taking too long time to execute, and this results in Forge are killing the script. Can I somehow avoid the killing of the deploy script?
My deploy script:
cd /home/forge/x.dk
git pull origin master
composer install --no-interaction --no-dev --prefer-dist
npm install
npm install gulp
gulp --production
php artisan migrate --force
Deployment log:
From gitlab.com:x/x
* branch master -> FETCH_HEAD
Already up-to-date.
Loading composer repositories with package information
Installing dependencies from lock file
Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. Run update to update them.
Nothing to install or update
Generating autoload files
> php artisan clear-compiled
> php artisan optimize
Generating optimized class loader
Compiling common classes
gulp#3.9.0 node_modules/gulp
├── interpret#0.6.6
├── pretty-hrtime#1.0.1
├── deprecated#0.0.1
├── archy#1.0.0
├── tildify#1.1.2 (os-homedir#1.0.1)
├── minimist#1.2.0
├── v8flags#2.0.10 (user-home#1.1.1)
├── chalk#1.1.1 (escape-string-regexp#1.0.3, supports-color#2.0.0, ansi-styles#2.1.0, has-ansi#2.0.0, strip-ansi#3.0.0)
├── semver#4.3.6
├── orchestrator#0.3.7 (stream-consume#0.1.0, sequencify#0.0.7, end-of-stream#0.1.5)
├── liftoff#2.2.0 (extend#2.0.1, rechoir#0.6.2, flagged-respawn#0.3.1, resolve#1.1.6, findup-sync#0.3.0)
├── vinyl-fs#0.3.14 (graceful-fs#3.0.8, strip-bom#1.0.0, vinyl#0.4.6, defaults#1.0.3, mkdirp#0.5.1, through2#0.6.5, glob-stream#3.1.18, glob-watcher#0.0.6)
└── gulp-util#3.0.6 (array-differ#1.0.0, array-uniq#1.0.2, beeper#1.1.0, lodash._reevaluate#3.0.0, lodash._reinterpolate#3.0.0, lodash._reescape#3.0.0, object-assign#3.0.0, replace-ext#0.0.1, vinyl#0.5.3, lodash.template#3.6.2, through2#2.0.0, multipipe#0.1.2, dateformat#1.0.11)
[17:43:36] Using gulpfile ~/x.dk/gulpfile.js
[17:43:36] Starting 'default'...
[17:43:36] Starting 'less'...
Fetching Less Source Files...
- resources/assets/less/style.less
Saving To...
- public/css/style.css
[17:43:37] Finished 'default' after 1.02 s
[17:43:41] gulp-notify: [Laravel Elixir] Less Compiled!
[17:43:41] gulp-notify: [Error in notifier] Error in plugin 'gulp-notify'
Message:
not found: notify-send
[17:43:41] Finished 'less' after 5.15 s
[17:43:41] Starting 'less'...
Fetching Less Source Files...
- resources/assets/less/admin-style.less
Saving To...
- public/css/admin-style.css
[17:43:45] gulp-notify: [Laravel Elixir] Less Compiled!
[17:43:45] gulp-notify: [Error in notifier] Error in plugin 'gulp-notify'
Message:
notify-send must be installed on the system.
[17:43:45] Finished 'less' after 4.18 s
[17:43:45] Starting 'scripts'...
Fetching Scripts Source Files...
- bower_components/jquery/dist/jquery.min.js
- bower_components/bootstrap/dist/js/bootstrap.min.js
Saving To...
- public/js/all.js
/home/forge/.forge/provision-1234567.sh: line 8: 21661 Killed gulp --production
I would avoid doing this NPM stuff in the deploy script:
npm install
npm install gulp
Probably what you need is to install Gulp via SSH and then just let the deploy script runs gulp --production on each push.
To access your server via SSH follow this Laracast: https://laracasts.com/series/server-management-with-forge/episodes/4. It explains how to connect to the database but it's basically the same.
When you have SSH access, install Gulp with:
sudo apt-get update
curl -sL https://deb.nodesource.com/setup | sudo bash -
sudo apt-get install -y nodejs
sudo npm install -g gulp
Hope it helps.

npm doesn't install global modules correct

There's a problem with installing my global modules properly.
My System
OS: OS X Mountain Lion
node.js: 0.10.18 (Package installer)
Steps to reproduce
Input
npm install coffee -g (or any other module)
Output
npm http GET https://registry.npmjs.org/coffee
npm http 200 https://registry.npmjs.org/coffee
{lots of dependencies}
coffee#0.0.1 /usr/local/lib/node_modules/coffee
├── node-getopt#0.2.3
├── modular-amd#0.1.2
├── chai#1.7.2 (assertion-error#1.0.0)
├── mocha#1.11.0 (growl#1.7.0, debug#0.7.2, commander#0.6.1, diff#1.0.2, mkdirp#0.3.5, ms#0.3.0, jade#0.26.3, glob#3.2.1)
├── express#3.2.6 (methods#0.0.1, fresh#0.1.0, range-parser#0.0.4, cookie-signature#1.0.1, buffer-crc32#0.2.1, cookie#0.1.0, debug#0.7.2, commander#0.6.1, mkdirp#0.3.4, send#0.1.0, connect#2.7.11)
├── sinon#1.7.3 (buster-format#0.5.6)
└── sinon-chai#2.4.0
Input
coffee
Output
-bash: coffee: command not found
Other information
npm config get prefix: /usr/local
Read/Write access für /usr/local: Yes
$PATH: /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin
/usr/local/share/npm exists: No
/usr/local/lib/node_modules/coffee exists: Yes
/usr/local/bin/coffee exists: No
What else can I do?
I won't add the direct link to coffee to my $PATH-variable, because that's not my job, that's the job of npm! Really, why should I use npm when I could do it by myself? I read that answer like 100 times and I have no words for this, which aren't against the rules on SO.
If you want to install CoffeeScript globally (as one of the tags suggests), you shall install coffee-script (not coffee).
Additionally, sudo is required for installing global module on the Mac.
Command:
sudo npm install coffee-script -g
Input
% coffee
Output
coffee>

karma command not found when karma already installed

I used node.js to install karma. My first try failed when running the following command on Terminal:
npm install -g karma
That failed so I decided to use:
sudo npm install -g karma
After entering my password it seemed to install correctly.
I am pasting part of the output of the install, maybe it will mean something to someone and it will be relevant to my question. After all the npm http messages this is what I see:
> ws#0.4.27 install /usr/local/share/npm/lib/node_modules/karma/node_modules/socket.io/node_modules/socket.io-client/node_modules/ws
> (node-gyp rebuild 2> builderror.log) || (exit 0)
CXX(target) Release/obj.target/bufferutil/src/bufferutil.o
SOLINK_MODULE(target) Release/bufferutil.node
SOLINK_MODULE(target) Release/bufferutil.node: Finished
CXX(target) Release/obj.target/validation/src/validation.o
SOLINK_MODULE(target) Release/validation.node
SOLINK_MODULE(target) Release/validation.node: Finished
/usr/local/share/npm/bin/karma -> /usr/local/share/npm/lib/node_modules/karma/bin/karma
karma#0.8.6 /usr/local/share/npm/lib/node_modules/karma
├── pause#0.0.1
├── dateformat#1.0.2-1.2.3
├── xmlbuilder#0.4.2
├── colors#0.6.0-1
├── chokidar#0.6.2
├── growly#1.1.1
├── mime#1.2.9
├── q#0.9.6
├── rimraf#2.1.4 (graceful-fs#1.2.3)
├── coffee-script#1.6.3
├── minimatch#0.2.12 (sigmund#1.0.0, lru-cache#2.3.0)
├── optimist#0.3.5 (wordwrap#0.0.2)
├── glob#3.1.21 (inherits#1.0.0, graceful-fs#1.2.3)
├── LiveScript#1.0.1 (prelude-ls#1.0.1)
├── log4js#0.6.6 (dequeue#1.0.3, semver#1.1.4, async#0.1.15, readable-stream#1.0.2)
├── lodash#1.1.1
├── http-proxy#0.10.3 (pkginfo#0.2.3, utile#0.1.7)
├── istanbul#0.1.22 (abbrev#1.0.4, which#1.0.5, fileset#0.1.5, nopt#2.0.0, wordwrap#0.0.2, async#0.1.22, mkdirp#0.3.5, esprima#0.9.9, escodegen#0.0.24, handlebars#1.0.12)
└── socket.io#0.9.16 (base64id#0.1.0, policyfile#0.0.4, redis#0.7.3, socket.io-client#0.9.16)
Then when I try to run the following command to create a karma config file with this command:
karma init karma.config.js
this is the message that gets returned:
-bash: karma: command not found
I have tried the same command with sudo before it but I get the same result.
Does anyone have any idea as to what is going on?
Any help is appreciated.
*Update!
I decided to check a file named: builderror.log
located in: /usr/local/share/npm/lib/node_modules/karma/node_modules/socket.io/node_modules/socket.io-client/node_modules/ws
This is what it shows:
gyp WARN EACCES user "root" does not have permission to access the dev dir "/Users/eperez/.node-gyp/0.10.5"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/share/npm/lib/node_modules/karma/node_modules/socket.io/node_modules/socket.io-client/node_modules/ws/.node-gyp"
gyp http GET http://nodejs.org/dist/v0.10.5/node-v0.10.5.tar.gz
gyp http 200 http://nodejs.org/dist/v0.10.5/node-v0.10.5.tar.gz
#mayankcpdixit gave the answer up there in a response to the OP's original question, but I'll put it here again in case anyone misses it.
You do not need to uninstall everything, and if I had to manually add a new path link for every npm package I try to install I'd probably shoot myself.
npm install -g karma-cli
Boom. Now you have karma command lines installed. Just like Grunt.
Edit: Please don't forget to upvote #mayankcpdixit as well, he commented directly on the original post, but didn't actually "answer" the question.
In your ~/.bash_profile (or similar) amend your PATH to include npm-installed binaries:
export PATH="$PATH:/usr/local/share/npm/bin"
I had this very same issue, and found this solution to be less time-consuming and impactful than completely re-installing node.
EDIT this has also worked for others in bash_profile
export PATH="$PATH:/usr/local/lib/node_modules/karma/bin"
It is recommended to install karma with its Command-Line-Interface (karma-cli) which will take care of fetching the appropriate karma. You can also install a different local version specific to each project you're working on and karma-cli will pick the appropriate one.
From the karma installation page:
Typing ./node_modules/karma/bin/karma start sucks so you might find it useful to install karma-cli globally:
npm install -g karma-cli
Now, check that karma was installed by typing:
karma start
You can also check that karma was installed by going to this directory:
cd /usr/local/lib/node_modules/karma
Good luck!
Don't need to completely uninstall node.js
Just
sudo rm -rf /usr/local/lib/node_modules/npm/
Then
install node.js
Then
reinstall karma
This worked for me.
I had to add export PATH="$PATH":/usr/local/lib/node_modules/npm/node_modules/karma/bin after installing karma with sudo npm install karma.
hope this helps.
Just go to test.sh:
Find: $BASE_DIR/../node_modules/karma/bin/karma start $BASE_DIR/../config/karma.conf.js $*
Replace with: /usr/local/bin/karma start $BASE_DIR/../config/karma.conf.js $*
Or: karma start $BASE_DIR/../config/karma.conf.js $*
I was also facing the same issue. It looks like karma for command line is a separate package which can be installed by
npm install -g karma-cli
When upgrading from Karma 0.10 to 0.12 the link to the karma executable is removed.
You can get it back with
cd node_modules/.bin
ln -s ../karma/bin/karma karma
Try re-installing node.js. There are lots of ways to install it, but I recommend downloading from nodejs.org
If that doesn't work, you may try to re-install karma.

Resources