Update npm module, but showing different older version in my console window - node.js

I wanted to install the latest version of socket.io, and the latest ver seems to be 1.45.socket.io download
To do this, I just type the following command.
npm install socket.io
However, when I checked installed modules in my laptop, socket.io's version did not change as can be seen below.
YANAGISAWAYUMA-no-MacBook-Pro:~ yanagisawa_yuma$ npm list --depth=0
yanagisawa_yuma#0.0.0 /Users/yanagisawa_yuma
├── ar-drone#0.3.3 extraneous (git://github.com/felixge/node-ar-drone.git#228bd4573e765bed3861f259ce7e66fcace15f43)
├── express#4.9.0
├── gulp#3.9.0
├── node#0.0.0
├── node-osc#1.1.0 extraneous
├── node-static#0.7.3
├── socket.io#1.1.0
└── static#2.0.0
What am I missing?

Instead of simply npm install socket.io,
try npm install socket.io#version

Related

npm dependencies pull in different versions of the same package

Wondering if someone can help me understand why this is happening. I have two npm packages that use tar-fs#2.1.0 but that package pulls in different versions of tar-stream. It is defined in the package.json as "tar-stream": "^2.0.0" but they resolve to different patch versions when running npm install. Reading about caret-ranges I'm not seeing anything to explain this.
I tried deleting the node_modules and lock file, running npm update tar-stream, and running npm install --package-lock-only to update the lock file based on 'package.json'. Any help is appreciated.
$ npm ls tar-stream
project#1.2.0 /Users/akerr/Documents/GitHub/project
├─┬ chrome-aws-lambda#5.3.0
│ └─┬ lambdafs#2.0.0
│ └─┬ tar-fs#2.1.0
│ └── tar-stream#2.1.3
└─┬ puppeteer-core#5.3.0
└─┬ tar-fs#2.1.0
└── tar-stream#2.1.4

yoeman/ubuntu: not recognized yo command

I am trying to install yoeman in ubuntu (via terminal) and I can't execute the command yo because it is not found. These are the steps I am using:
dmr#xxxxxxxxxxx:/home$ sudo npm install yo -g
npm WARN deprecated npmconf#2.1.2: this package has been reintegrated into npm and is now out of date with respect to npm
-
> spawn-sync#1.0.15 postinstall /home/xxxxxxxxxxx/.npm/lib/node_modules/yo/node_modules/yeoman-environment/node_modules/inquirer/node_modules/external-editor/node_modules/spawn-sync
> node postinstall
> spawn-sync#1.0.15 postinstall /home/xxxxxxxxxxx/.npm/lib/node_modules/yo/node_modules/tabtab/node_modules/inquirer/node_modules/external-editor/node_modules/spawn-sync
> node postinstall
/home/xxxxxxxxxxx/.npm/bin/yo -> /home/xxxxxxxxxxx/.npm/lib/node_modules/yo/lib/cli.js
/home/xxxxxxxxxxx/.npm/bin/yo-complete -> /home/xxxxxxxxxxx/.npm/lib/node_modules/yo/lib/completion/index.js
> yo#1.8.4 postinstall /home/xxxxxxxxxxx/.npm/lib/node_modules/yo
> yodoctor
Yeoman Doctor
Running sanity checks on your system
✔ Global configuration file is valid
✔ NODE_PATH matches the npm root
✔ Node.js version
✔ No .bowerrc file in home directory
✔ No .yo-rc.json file in home directory
✖ npm version
Your npm version is outdated.
Upgrade to the latest version by running:
npm install -g npm
Found potential issues on your machine :(
yo#1.8.4 /home/xxxxxxxxxxx/.npm/lib/node_modules/yo
├── cli-list#0.1.8
├── titleize#1.0.0
├── async#1.5.2
├── humanize-string#1.0.1 (decamelize#1.2.0)
├── opn#3.0.3 (object-assign#4.1.0)
├── user-home#2.0.0 (os-homedir#1.0.1)
├── figures#1.7.0 (escape-string-regexp#1.0.5, object-assign#4.1.0)
├── string-length#1.0.1 (strip-ansi#3.0.1)
├── chalk#1.1.3 (escape-string-regexp#1.0.5, ansi-styles#2.2.1, supports-color#2.0.0, has-ansi#2.0.0, strip-ansi#3.0.1)
├── repeating#2.0.1 (is-finite#1.0.1)
├── sort-on#1.3.0 (arrify#1.0.1, dot-prop#2.4.0)
├── root-check#1.0.0 (sudo-block#1.2.0, downgrade-root#1.2.2)
├── yeoman-character#1.1.0 (supports-color#3.1.2)
├── parse-help#0.1.1 (execall#1.0.0)
├── cross-spawn#3.0.1 (lru-cache#4.0.1, which#1.2.10)
├── yosay#1.2.0 (ansi-regex#2.0.0, strip-ansi#3.0.1, ansi-styles#2.2.1, wrap-ansi#2.0.0, cli-boxes#1.0.0, pad-component#0.0.1, string-width#1.0.2, taketalk#1.0.0)
├── package-json#2.3.3 (registry-url#3.1.0, semver#5.3.0, rc#1.1.6)
├── got#5.6.0 (lowercase-keys#1.0.0, timed-out#2.0.0, is-redirect#1.0.0, is-plain-obj#1.1.0, is-stream#1.1.0, node-status-codes#1.0.0, duplexer2#0.1.4, is-retry-allowed#1.1.0, read-all-stream#3.1.0, unzip-response#1.0.0, object-assign#4.1.0, pinkie-promise#2.0.1, url-parse-lax#1.0.0, create-error-class#3.0.2, readable-stream#2.1.5, parse-json#2.2.0)
├── configstore#1.4.0 (object-assign#4.1.0, os-tmpdir#1.0.1, graceful-fs#4.1.6, xdg-basedir#2.0.0, uuid#2.0.2, osenv#0.1.3, write-file-atomic#1.2.0, mkdirp#0.5.1)
├── inquirer#0.11.4 (strip-ansi#3.0.1, ansi-regex#2.0.0, ansi-escapes#1.4.0, rx-lite#3.1.2, through#2.3.8, cli-width#1.1.1, string-width#1.0.2, readline2#1.0.1, cli-cursor#1.0.2, run-async#0.1.0)
├── npm-keyword#4.2.0 (object-assign#4.1.0, pinkie-promise#2.0.1, registry-url#3.1.0)
├── update-notifier#0.6.3 (is-npm#1.0.0, latest-version#2.0.0, semver-diff#2.1.0, boxen#0.3.1, configstore#2.0.0)
├── meow#3.7.0 (map-obj#1.0.1, trim-newlines#1.0.0, decamelize#1.2.0, object-assign#4.1.0, camelcase-keys#2.1.0, minimist#1.2.0, redent#1.0.0, loud-rejection#1.6.0, normalize-package-data#2.3.5)
├── fullname#2.1.0 (pify#2.3.0, pinkie-promise#2.0.1, npmconf#2.1.2)
├── read-pkg-up#1.0.1 (find-up#1.1.2, read-pkg#1.1.0)
├── yeoman-doctor#2.1.0 (object-values#1.0.0, log-symbols#1.0.2, semver#5.3.0, each-async#1.1.1, bin-version-check#2.1.0, twig#0.8.9)
├── insight#0.7.0 (object-assign#4.1.0, tough-cookie#2.3.1, lodash.debounce#3.1.1, os-name#1.0.3, inquirer#0.10.1, request#2.74.0)
├── lodash#3.10.1
├── yeoman-environment#1.6.3 (log-symbols#1.0.2, escape-string-regexp#1.0.5, text-table#0.2.0, untildify#2.1.0, debug#2.2.0, diff#2.2.3, globby#4.1.0, mem-fs#1.1.3, grouped-queue#0.3.2, inquirer#1.1.2, lodash#4.15.0)
└── tabtab#1.3.2 (object-assign#4.1.0, minimist#1.2.0, debug#2.2.0, mkdirp#0.5.1, npmlog#2.0.4, inquirer#1.1.2)
I execute yo and command is not recognized.
Reading the result I see npm version is not installed to the latest version. I execute then:
sudo npm install -g npm
xxxxxx#xxxxxxxxxx:/home$ sudo npm install -g npm
/home/xxxxxx/npm/bin/npm -> /home/xxxxx/.npm/lib/node_modules/npm/bin/npm-cli.js
npm#3.10.6 /home/xxxxxx/.npm/lib/node_modules/npm
and get current version is:
xxxxxxxx:/home$ npm -v
2.15.9
I dont know if it really is the latest version of npm.
What is happening? What is wrong in the commands of linux?
I found the solution...
I am new in ubuntu and today when I turn on the ubuntu had packages corrupted... specially start stoped in npm package.
I reinstalled ubuntu and now I could install last version of npm 3.10.6 and after it yo (yeoman for angular)
I dont know if after this situation I can repare packages bad installed

Globally installed npm package not accessible in terminal

I installed protractor through npm install -g protractor which run successfully.
Running npm -g ls --depth=0 shows protractor installed correctly.
azim#azim-desktop:~$ npm -g ls --depth=0
/home/azim/npm-global/lib
├── express-generator#4.13.1
├── generator-angular#0.12.1
├── generator-chrome-extension#0.3.1
├── generator-gulp-angular#1.0.2
├── generator-gulp-angular-subtask#0.9.1
├── generator-karma#1.0.0
├── generator-mocha#0.1.8
├── generator-react-webpack#3.2.2
├── git-remote-mango#0.0.2
├── jshint#2.7.0
├── jsx#0.9.89
├── mango-admin#0.1.1
├── n#2.1.0
├── npm#3.7.2
├── protractor#4.0.0
└── yo#1.6.0
but protractor isn't accessible in terminal.
azim#azim-desktop:~$ protractor
protractor: command not found
It was working fine a while ago, I've updated my npm and node to latest versions. I think after that the PATH variables messed up. Googled for a solution but didn't work anything. I don't want to mess up the current situation.
Current path is:
azim#azim-desktop:~$ echo $NODE_PATH
/usr/lib/nodejs:/usr/lib/node_modules:/usr/share/javascript:/home/azim/npm-global/lib/node_modules
Versions:
azim#azim-desktop:~$ npm --version
2.14.12
azim#azim-desktop:~$ node --version
v4.3.1
The environment variable $NODE_PATH is used by node to look for modules only.
Essentially you'll want to make sure that the directory path, where the protractor binary is located, is accessible through the environment variable $PATH instead.
Example of where my protractor is installed:
root#codeblog:~# which protractor /usr/bin/protractor
root#codeblog:~# env | grep PATH
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
NODE_PATH=/usr/lib/nodejs:/usr/lib/node_modules:/usr/share/javascript
If you got protractor installed at another place then you might want to tweak your ~/.bashrc to append that directory into the $PATH variable.
Like:
PATH=$PATH:/usr/my_protractor_dir/bin

express: command not found , has worked before?

I'm working on a OSX 10.10.4, I have worked with node.js and express before on this computer.
But now when I want to start a new application, the computer won't recognize the command express anymore.
I've tried installing it with all these commands:
- npm install express
- npm install -g express
- npm install express -g
- sudo npm install -g express
- sudo npm install express -g
- npm install express-generator
- npm install -g express-generator
- npm install express-generator -g
- sudo npm install -g express-generator
- sudo install express-generator -g
- sudo npm install -g express-generator#3
- sudo npm install -g express-generator#4
But it still doesn't recognize the command express
This is the output when I install without the -g
npm install express
express#4.13.3 node_modules/express
├── escape-html#1.0.2
├── merge-descriptors#1.0.0
├── cookie#0.1.3
├── array-flatten#1.1.1
├── utils-merge#1.0.0
├── cookie-signature#1.0.6
├── methods#1.1.1
├── fresh#0.3.0
├── range-parser#1.0.2
├── vary#1.0.1
├── path-to-regexp#0.1.7
├── content-type#1.0.1
├── etag#1.7.0
├── parseurl#1.3.0
├── content-disposition#0.5.0
├── serve-static#1.10.0
├── depd#1.0.1
├── qs#4.0.0
├── finalhandler#0.4.0 (unpipe#1.0.0)
├── on-finished#2.3.0 (ee-first#1.1.1)
├── debug#2.2.0 (ms#0.7.1)
├── proxy-addr#1.0.8 (forwarded#0.1.0, ipaddr.js#1.0.1)
├── type-is#1.6.6 (media-typer#0.3.0, mime-types#2.1.4)
├── accepts#1.2.12 (negotiator#0.5.3, mime-types#2.1.4)
└── send#0.13.0 (destroy#1.0.3, statuses#1.2.1, ms#0.7.1, mime#1.3.4, http-errors#1.3.1)
and when I install with the -g
sudo npm install -g express-generator
Password:
/Users/Maiteh/.node/bin/express -> /Users/Maiteh/.node/lib/node_modules/express-generator/bin/express
express-generator#4.13.1 /Users/Maiteh/.node/lib/node_modules/express-generator
├── sorted-object#1.0.0
├── commander#2.7.1 (graceful-readlink#1.0.1)
└── mkdirp#0.5.1 (minimist#0.0.8)
I have tried some other stuff like the PATH and nodejs-legacy, but none of them work.
With the sudo apt-get install nodejs-legacy the computer doesn't find the command apt-get.
The reason I got express:command not found after I installed was because my $PATH didn't know where express was.
To anyone wanting to install the express command line tools I did this
sudo npm install express-generator -g
which resulted in
/usr/local/share/npm/bin/express -> /usr/local/share/npm/lib/node_modules/express-generator/bin/express
express-generator#4.13.1 /usr/local/share/npm/lib/node_modules/express-generator
├── sorted-object#1.0.0
├── commander#2.7.1 (graceful-readlink#1.0.1)
└── mkdirp#0.5.1 (minimist#0.0.8)
when I tried express --version I got a command not found
Open your bash_profile from terminal with open ~/.bash_profile
After that add the path you got after you installed express, in my case it was
/usr/local/share/npm/lib/node_modules/express-generator/bin/express
Add this to your bash_profile
export PATH=/usr/local/share/npm/lib/node_modules/express-generator/bin:$PATH
Save the file and go back to terminal. Enter hash -r and then quit terminal and start it again.
Now if you try express --version for example you should see that the command line tools are working.
There's kind of a mishmash of problems you're describing here, so I'll try to address them one at a time.
Express is a popular framework for node.js. The typical way to add it to your project is to do npm install --save express and then it will save it into your package.json file and install it into node_modules. Adding -g to that command would attempt to install it globally, but that's not how express is used. Express is used on a per-project basis. See their website for details.
In the big list of commands you've run, you mention express-generator. Express-generator is a tool that lets you quickly build out some boilerplate to make starting an express project a bit easier. Since express-generator is meant to be run globally and not inside a project, you DO install it with the -g flag. See their website for details on use and installation.
You're trying to install some more node stuff with the apt-get command. That command is used for package management on Linux (typically Ubuntu/Debian) machines. Mac OS X doesn't come with it (and you absolutely don't need it). Any instructions that mention running apt-get are not targeted towards Mac users.
Essentially, I don't think you have a problem, the logs you show are exactly what I'd expect to see. Generate a boilerplate project with express-generator and you should be all set to start working on your express project. Good luck!

Express app will not start with node app.js

I was following along to this tutorial about setting up an express app. But when I ran node app.js the server would not start. The previous command that I ran was
cd express_example && npm install
But I got this error
npm WARN engine express#4.9.8: wanted: {"node":">= 0.10.0"} (current: {"node":"0.8.4","npm":"2.1.4"})
npm WARN engine void-elements#1.0.0: wanted: {"node":">=0.10.0"} (current: {"node":"0.8.4","npm":"2.1.4"})
So i thought that it was because a newer version of node was necessary. So I looked at the version of node that I had, noticed it was older so I tried upgrading. But when I ran brew update node i got this alert.
Error: node-0.10.32 already installed
I did some searching around and found this answer here on SO. Which suggested running these commands
sudo npm cache clean -f
then
sudo npm install -g n
then
sudo n stable
But the server still wont startup. But at least I am now at v0.10.33
I also found this similar question on SO whose accepted answer said to try sudo node app.js but that just does not seem right, nor did it even work.
If you are using Express 4 and using the generator, there is a slightly diffrent method for running the app. Express 4 changed the file structure to:
├── app.js
├── bin
│ └── www
├── package.json
├── public
│ ├── images
│ ├── javascripts
│ └── stylesheets
│ └── style.css
├── routes
│ ├── index.js
│ └── users.js
└── views
├── error.jade
├── index.jade
└── layout.jade
Notice the bin/www directory.
The app start logic is now seperated in the bin/www file. Therefore you have to run your app with the following command:
DEBUG=<<app_name>> ./bin/www
Reference: http://expressjs.com/starter/generator.html

Resources