Cannot run globally installed node modules in Windows 7 - javascript

Note: I have tried almost all similar posts related to this issue and found nothing was helpful to me. Hence posting this.
Issue: I'm trying to install http-server package in my Windows 7 machine using npm install http-server -g, Installation was fine, however when I try to execute it using http-server command in the command line I'm getting an error saying, 'http-server' is not recognized as an internal or external command, operable program or batch file. I have also tried the same steps for gulp and the result was the same.
I have tried setting the Node Path as, set NODE_PATH=%AppData%\npm\node_modules; but no luck.
Can someone shed some light here?
Thanks,
Dave

Global packages needs to be installed using and administration console (CMD / Run as Administrator)

Related

Javascript issue installing npm packages (nodemon, express)

I'm new to js and trying to setup a simple project with express and nodemon via npm.
However, installing these packages does give me multiple errors (see below).
I am on Win 10, using the PowerShell & Atom IDE. Project is saved on Google Drive.
"Calc.js" is simply the name of my project.
I have node & npm installed and restarted pc multiple times before.
Then I set up the npm init
I begin to install the first package and get this error:
I try to install express, but get the same result, adding -g also does not make a difference. Now I install "ci", which works for some reason.
Now I have the node modules folder in my project, try to install express again, and it seems to kinda work (got the files in the node_modules folder).
However when I try to run the calc.js via "node calc.js" it
does not work.
Already tried out many things and even accidentally made it work, then tried to reproduce it and failed. Would be super happy for some help.

'run-s' is not recognized as an internal or external command, operable program or batch file

I surprisingly got that issue out of nowhere, when I was trying to use the npm link command testing my local package. Any thoughts?
Windows 10
node 15.9.0
npm 8.12.2
Seems that the issue was because my npm version didn't match my node version.
I was trying to install that 'run-s' package globally but it didn't help. I checked my environment variables but it didn't help either.
After all I just simply uninstalled nodejs, deleted all the files that it left and installed the needed version again (12.22.12 in my case) using "windows-nvm" and now everything runs smoothly.
Now my NodeJS version is 12.22.12
my NPM version is 6.14.16
Hope it will help somebody

How do I run a copied project in Node.js

https://github.com/gleitz/mahjong
I want to run this app on my windows,
the directions say:
-Install dependencies with npm update
-Start the application with node app.js
it's sound easy so I try myself.
1.Fist of all , I install node.js on it's official website (https://nodejs.org/en/)
I download the 8.9.3 version.
after installing node.js
2.open the command line and go to the project path.
3.then I input the command npm update.
it works,and the node_modules folder is created.But there are some warn message
4.finally input the command node app.js... it's not work with many error message
following is wrong message
I wonder know how should I do.Is any thing I didn't installed?
Please help me.I really want to research this mahjong project.
Before running npm update in the directory where you have your project, you should run npm install first to install all the required dependencies needed for the project to run.
So I advice to delete the node_modules directory that was created after you ran npm update, after which you can then run npm install. This should solve your issue.
Update: If you just want to try it online and not run it locally they've hosted a version on the web: http://gleitzman.com/apps/mahjong.
It's not your fault.
What you did was correct, but the project documentation needs to be updated. It's not a turn-key solution and you'll need to figure a few things out to get it working.
The error message is says it wants a mongo db instance, but you don't have one running. Try the mongodb home page or google for instructions. If you have docker it is pretty easy: docker run -it -p 27017:27017 mongo.
Even after spinning up mongodb I wasn't able to get the app to work locally. You could try contacting the repo maintainer for assistance. They may be happy to help given you've shown interest in their project.
Good Luck!

Not Getting $ in command prompt in Node.Js

My NodeJs is working fine but i have an issue I'm not seeing $ in the prompt as most example point.
Another issue is when i put sudo I dont get anything.Things I have tried are the following
$ sudo npm install npm -g
/usr/bin/npm -> /usr/lib/node_modules/npm/bin/npm-cli.js
npm#2.7.1 /usr/lib/node_modules/npm
given on the following Website
http://www.tutorialspoint.com/nodejs/nodejs_npm.htm
Apologies am very new to Node.JS.Please help
I'm going to explain this in terms familiar to MS windows.
$ npm --version
^ dollar sign is the same as "C:\" in windows.
It just means "from here..." in the most basic terms I can use.
You don't need the dollar sign for anything in that tutorial.
"sudo" means "elevate to an administrator level" similar to opening a command line terminal "in administrator mode." But for Linux (Ubuntu and Mac as *NIX) systems.
--version can be called as "-v" most of the time and means "for the thing I've named before, in this case "npm" show me the version.
Once you've installed NodeJS it comes with a "package manager" called NPM. The best way to relate this to windows is by considering it a command line version of an "installation" that installs different programs as you tell it to with different options.
"npm install -g" means "Hey NPM! Install to EVERYWHERE(call from command line/terminal/bash) the thing I Tell you next. "npm install -g express" for example, means hey NPM, install "expressJS" globally, so I can use the terminal to write commands(micro apps) from the expressJS I just installed with node.
"npm install --save" means hey, install this microapp, but ONLY let me use it in THIS EXACT FOLDER I'm in, and let anyone else that is in this folder know they need to install it to use this application I'm making.
"npm init" Is actually the FIRST thing you should do in any node project folder. It creates the "package.json" file in the current directory, and it will define the folder you're in as the folder to start installing stuff you "npm install" to the "node_modules" folder that will show in the folder you're currently in.
If you want to tinker with NodeJS code, and you don't want to tamper with your local machine and install all kinds of stuff you're not totally sure about yet you can use "REPL.it" (https://repl.it/languages/nodejs) the white window on the right is treated like a file you'd run in node. The dark window on the right is an actual NODE TERMINAL that you can run nodejs commands/code in directly.
There's one other good resources in general and that is here (https://devdocs.io/) it's called "Devdocs" and it has Node, npm, and express code examples, clean explanations, and examples that you can download directly to your local machine.
I hope that gets you moving with NodeJS. It's hard to understand, but with a bit of try and fail you'll start to try more and fail less. Cheers!

Problem with installing Node.JS on Windows

I'm trying to install Node.JS on Windows 7 with help of this tutorial.
I downloaded Cygwin, installed it. I have installed Python 2.7.
After this i downloaded last version of Node.JS in tar.gz. Than I opened cygwin bash and typed this command there:
tar zxvf node<tab>
It unzipped it to directory: node-v0.4.2
But what i need to do if i have python installed?
I tried to type:
make test
and got error message: make: command not found
I will be very grateful for any help!
Did you install all the required packages? Run setup.exe again and check.
I think the issue might be that the environment variables in Cygwin need to be configured:
Getting Make to place nice with Cygwin

Categories

Resources