how to install old version of express.js - node.js

How do I install the right version of express and do I have to uninstall 3.x before I install 2.x?
This is the tutorial I am trying to test: http://psitsmike.com/2011/09/node-js-and-socket-io-chat-tutorial/
I used this package.json:
{
"name": "mukhin_chat",
"description": "example chat application with socket.io",
"version": "0.0.1",
"dependencies": {
"express": "2.4.6",
"socket.io": "0.8.4"
}
}
and used the following command:
npm install -d
When I run the app I still get the question: ... are you migrating from Express 2.x to 3.x ...

This is pretty easy, to remove the current version of express, just type
npm uninstall express
Followed by the following command to install a specific version of a package:
npm install express#2.x.x

bro you just need to run this command and your version will be updated at any time.
npm i express#sepecifc version number
for example i was required to use the old version of express so i do like this
npm i --save express#3.20.1

Related

why I can't change Typescript version even though I have downgraded the version

so previously, I installed Typecript on my new macbook by running this command
sudo npm install typescript -g
and I got Typescript version 4.7.4. and then I want to deploy the function using this command
firebase deploy
unfortunately, there is a warning like this
WARNING: You are currently running a version of TypeScript which is
not officially supported by #typescript-eslint/typescript-estree.
You may find that it works just fine, or you may not.
SUPPORTED TYPESCRIPT VERSIONS: >=3.3.1 <4.1.0
YOUR TYPESCRIPT VERSION: 4.7.4
Please only submit bug reports when using the officially supported
version.
and then I downgrade to version 4.0.7, but unfortunately that warning still exist, it seems my app is still on v4.7.4 (cached ? ) I am sure I have changed the typescript version on package.json and I also check via terminal like the image below
but why my node app still have version v.4.7.4 ? not v.4.0.7 ? what should I do?
fiuhhh....after 2 days, I finally find the solution
I have to change the dependencies and also the devDependencies, especially these dependencies in the package.json
"dependencies": {
"firebase-admin": "^10.0.2",
"firebase-functions": "^3.18.0",
},
"devDependencies": {
"#typescript-eslint/eslint-plugin": "^5.12.0",
"#typescript-eslint/parser": "^5.12.0",
"eslint": "^8.9.0",
"eslint-config-google": "^0.14.0",
"eslint-plugin-import": "^2.25.4",
"typescript": "^4.5.4" // <-- watch this version
},
the problem is ....it seems to me that these dependencies is tightly coupled. it can easily break if it doesn't match. so my solution is to create new project just to copy and paste those dependencies combination above with the latest version recommended by firebase. watch this video if you are confused how to initialize cloud function project
first, Update your firebase tools to the latest version using this command
sudo npm install -g firebase-tools
and change to your directory and init the project
cd desktop
mkdir forCopyPasteDependenciesOnly
firebase init
select cloud function and typescript. and then you copy those dependencies above and paste it on your problematic project
in my case, I also change the typescript globally using the recommended typescript version from the project package.json that you just initialize (4.5.4, not 4.0.7 or 4.7.4 in my case )
sudo npm uninstall -g typescript
sudo npm install -g typescript#4.5.4
and then, in your problematic project, delete your node-modules folder
and delete your package-lock.json. and finally run these 2 commands below
npm cache clean –force
npm install
and when you run firebase deploy you may see errors, but luckily it just error from eslint you just update, you can solve it easily.
I hope it helps
You installed typescript as globally on your system but you changed just in your package.json.
First you should type this npm uninstall -g typescript.
Then npm install -g typescript#your version.
After that you can uninstall your local tsc on your project.

npm won't install the specified version of hardhat

I am trying to install hardhat and make it works. When I try npm install --save-dev hardhat and then check the installed version in package.json:
"devDependencies": {
"hardhat": "^0.0.7"
}
But I am trying to install the latest version. Last time I checked, the latest version is 2.8.3. So I tried to install it with npm install --save-dev hardhat#2.8.3. But It still gives me the same version of 0.0.7.
Try changing the version of the package in your package.json itself.
from :
"devDependencies": {
"hardhat": "^0.0.7"
}
to :
"devDependencies": {
"hardhat": "^2.8.3"
}
and run npm install to install the the specified version.
I just tried to reproduce the same way you tried... but it worked for me.. Please try with the above method and pls let me know your feedback in the comments.
Thank you

Can't install laravel-elixir because of node-sass failure

I am pretty new to this environment still and am trying to get up to speed on node.js modules and Laravel (5.1.11) as a whole, so...
I have a fresh install of Laravel implemented by the cPanel Installitron. I'm using PHPStorm to install all of the node modules via the provided package.json:
package.json
{
"private": true,
"devDependencies": {
"gulp": "^3.8.8"
},
"dependencies": {
"laravel-elixir": "^3.0.0",
"bootstrap-sass": "^3.0.0"
}
}
The error I get when I run the install is:
Cannot download "https://github.com/sass/node-sass/releases/download/v3.13.1/win32-x64-57_binding.node":
HTTP error 404 Not Found
I can understand why this would happen, seeing as that is an older version of node-sass, but how do I know what newer versions are compatible with the requested version of laravel-elixir? I didn't want to just install a newer version of node-sass because digging a deeper hole would make it harder for me to find a solution to my problem. What is the fix for this?
It looks like you can fix this by installing Windows Build Tools via this command:
npm install --global --production windows-build-tools
Then delete the project's node_modules folder and re-run npm install.
Just follow this official url well doc.: https://laravel.com/docs/5.3/elixir if you get any error. I just comment and i ll be here.

SailsJS : How to get all current installed module versions in a Project

I would like to ask how to determine the Express version that is being used of the SailsJS. I know that Sails JS is built on top of Express.
I am using the version below:
"dependencies": {
"ejs": "~0.8.4",
.
.
.
"rc": "~0.5.0",
"sails": "~0.11.2",
"sails-disk": "~0.10.0"
}
I am asking this because I want to install this module https://github.com/rguerreiro/express-device and use with sailsJS.
In this particular module, the version is dependent on the Express version that is why I need the Express ver in order to install the appropriate express-device version.
I have seen also how to use it with sails in this post: using express-device with sails
The thing is it was 2 years ago and Express had fewer version and the latest can be installed.
Cheers!
You can output npm dependency tree with
npm ls --depth=1
Ref: https://docs.npmjs.com/cli/ls

npm install not working in windows 7 without giving any error

I am new to node and have installed latest version of nodejs on windows 7 from windows installer for node.
For me node install is not working without giving any error.
After giving command
npm install -g express
Cursors just waits and waits without showing any error message
node(v 0.12.2) and npm(v2.7.4)
Any help is highly appreciated. Thanks!!
had the same problem once,
in case you installed some node packages before and there is already an node_modules folder try to delete it manually and rerun the npm install command.
alternatively try to create a package.json file like this:
package.json
{
"name": "module-name",
"version": "1.0.0",
"description": "",
"author": "Your Name",
"dependencies": {
"express": "4.2.x"
},
"license": ""
}
and run npm install in that folder
EDIT:
just mentioned you try to install express globally, this is not needed, express is installed via npm install express --save (--save creates a dependency in the package.json file).
npm install express --save
express-generator
Another option would be to install the express-generator ,this one is installed globally ;)
npm install express-generator -g
and generate your initial project this way
check the proxy settings.
npm config get proxy
If proxy is correct then you might had cancelled the installation in the middle.
If you had done so, delete the folder named "node_modules" in your current directory (installation folder)which will be created while installation.
and restart the install (type npm install )

Resources