php -S localhost:8000 not running in node.js - node.js

I have installed NPM and bower globally as well as gulp and I am trying to run the following command on a windows machine:
php -S localhost:8000
Its saying php is not recognized as an internal or external command. Can someone tell me what I am doing wrong here?
THanks

Installing PHP solved this for me, specifically following this tutorial:
https://www.youtube.com/watch?v=6Y6lOHov3Bk

Related

Express - Command not found

I am trying to run express on my mac.
I have installed express generator using the following command -
sudo npm install express-generator -g
I have also tried every alternative command under the sun, no sudo etc. and it tells me it has installed fine. I get this message -
/usr/local/Cellar/node/10.8.0/bin/express -> /usr/local/Cellar/node/10.8.0/lib/node_modules/express-generator/bin/express-cli.js
+ express-generator#4.16.0
added 10 packages from 13 contributors in 1.202s
But when I try run -
express testproj
I get this -
-bash: express: command not found
I've exhausted so many suggested solutions on stack. Does anyone have any ideas?
You will have to add the npm\bin directory to your PATH like this,
export PATH="/usr/local/bin/npm:/usr/local/bin/node:/usr/local/bin:$PATH"
Once done, try executing your express testproj command.
Hope this helps!
In my Mac OS, I use the below command, it works for me.
export PATH="/usr/local/Cellar/node/10.8.0/bin:$PATH"

node.js on plesk onyx, npm commands are not working via ssh

I have installed node.js on plesk onyx via the plesk extension manager. I am trying to install the node.js driver for mongodb. This is done via ssh using npm. However, no npm commands are being recognised.
Node.js is working as I have setup a test app successfully.
I am thinking that the way in which plesk installs node.js doesnt seem to allow for ssh npm access?
Can anyone shed any light on this please?
Have you tried to use
/opt/plesk/node/6/bin/npm
or
/opt/plesk/node/7/bin/npm
command?
Had the same issue, what i did was aquick find from ssh command line:
find / -name npm
Spotted the right npm in my environment:
# find / -name npm
/var/www/vhosts/mibro.help/.nodenv/shims/npm
/opt/plesk/node/12/bin/npm
And then use this path to run npm!
Hope this helps.

node -bash: /usr/sbin/node: No such file or directory

I am having this error with node. Running Debian 7 (Wheezy) a VPS.
I have this error if I for example run this command (in the directory of the .js)
node sell.js
or
screen node sell.js
They both don't work, because I am getting this error:
-bash: /usr/sbin/node: No such file or directory
Can somebody help me?
As in #Quentin's answer, the name of the executable may be incorrect. In many cases, what got installed was nodejs, not node. The line below creates a symbolic link that points to nodejs from where your system looks when you type node. It is a work-around - an alternative to simply typing nodejs
sudo ln -s /usr/bin/nodejs /usr/sbin/node
The Debian package for NodeJS is called nodejs and installed the executable /usr/bin/nodejs.
node is the wrong program, it is for ham radio operations, and your install of it appears to be broken anyway).
I ran the command:
sudo apt-get install nodejs-legacy
and nodejs worked again!
Maybe something wrong happened during your node's installing.
And system environment variable shows the command "node" referes to /usr/sbin/node .
Try download node linux binaries from official. Rename and put it in /usr/sbin after extracting the source. Of course you can put it in another folder as long as you update the system environment variables.

installing nodejs module doesnt give me the command

I am trying to run pixel-ping and running into trouble. I followed these instructions:
http://documentcloud.github.io/pixel-ping/
and it mentions that Installing Pixel Ping gives you the pixel-ping command. but when I type pixel-ping path/to/config.json it returns -bash: pixel-ping: command not found
I am not sure why it would say that any ideas would be greatly appreciated. I have both nodejs and npm installed I have other modules working perfectly. Am I doing something wrong ?
curl npmjs.org/install.sh | sudo sh
Install Pixel Ping via NPM:
sudo npm install -g pixel-ping
Restart shell
Also ensure
~/npm/bin is in the Path

'Express' is not recognized command (windows)

Okay I am running node on windows (7). Using npm I just installed modules to d:\ directory. Therefore my files structure looks like the following:
D:\
-myproject
-node_modules
-.bin
-express
However, when I am in this 'myproject' directory, I can't seem to run 'express' for example:
D:\myproject\express site
'express' is not recognized as an internal or external command, operable program or batch file.
Am I doing anything wrong?
Try:
npm install -g express-generator#3
That solved problem for me.
Edit: for version 4
npm install express-generator -g
Description:
express is the package for dependency of express js.
express-generator is the package for enabeling express command and create a sample project, etc.
Assuming that this is kept separate for the decoupling of project dependency with cli tool of express.
Another SO ref: https://stackoverflow.com/a/41311733/1666582
Here's what to type in the command line to make it work in windows:
npm install express-generator -g
[Source: http://expressjs.com/starter/generator.html]
My guess is that you didn't install Express globally. You can install express globally (and therefore available in your PATH) with the following command (see http://expressjs.com/guide.html) :
npm install -g express
The way you install it is available only in the folder that you installed it and there is nothing wrong with that approach. There is very little advantage of having it available globally.
If express is not in your PATH you can run it by entering the full path to it:
\myproject\node_modules\.bin\express.cmd
With the release of Express 4.0.0 it looks like you need to do
npm install -g express-generator
We need to set path for express global directory
C:\Users[User_Name]\AppData\Roaming\npm\
After add a new path, please reopen the CMD console
Tried all of these and never worked. A repair of Node.js by kicking of installation and selecting repair option does the magic.
Cheers
What worked for me was:
I used the windows command prompt instead of the node.js command prompt.
In windows 10 simply type in the windows search bar for "node"
You see a node.js desktop app and a node js command prompt.
Choose the "node js command prompt"
Type in the command prompt
npm install express-generator -g
Then navigate somewhere and type in:
express your-website-text-here -e
A directory with express files will be generated. Also now you won't see the express error.
I was able to fix with the following package install:
npm install express-generator -g
Thanks
When you install Node.js, the below path is added to the Windows OS %Path% variable, I'm presuming similar happens on other operating systems as well:
C:\Users\<your-windows-username>\AppData\Roaming\npm
In my case, because I use a work Windows laptop for an employer that severely restricts what employees can do on their machines (I.e. many actions require elevated admin privileges), Node.js was being prevented from adding the above path to the Windows %Path% environment variable, and much to my chagrin the Node.js installation was silent about it. Navigate to above folder and you will notice the express command lives there, see screenshot below.
How did I figure this out? I did a fresh installation of Node.js on a personal, home Windows machine that has no admin privilege restrictions like my work machine does, compared the before and after %Path% value, and noticed the addition of that path. My work machine was missing it.
I had no choice but to add the path manually to %Path%, and then express was recognized from within any path I ran it.
I was able to fix this with:
npm install express-generator -g
I tried all the above solution, no luck for me.
Open "Node.js" command prompt and tried as administrator. It is working fine for me. Don't try with windows command prompt.
I have the same problem and understand the solution, but i can´t undestand why, running npm install -g express, express.bat isn´t added automatically to Path.
Running with npm install -g express have the same result. Download packages and store in node_modules, but express.bat isn´t added to path.
Run the node command prompt as administrator and then install express globaly
npm install -g express
and then go to folder where you want to install express generator, open command prompt there and run this command
npm install express-generator, it will then fix the issue
I have tried out all above solutions, but its did't worked for me, finally I have re-installed the node.js with newer version and started to express install process again. Its worked for me.
npm install -g express
npm install -g express-generator
What command are you using to open the directory?
That error means CMD can't find the "express" executable in the current directory.
Use the "PUSHD" command or "CD /D" instead of "CD"
#Echo OFF
PUSHD "D:\myproject\express" || (Echo bad folder)
express.exe "site"
Pause&Exit
Express is loaded someplace else and not in the windows path environment variable. You need to find were express.exe is installed and add the path. Maybe something like ;"C:\Program Files\Express\bin";
Running "npm install express" and "npm install express-generator" from your project directory will resolve the issue (if that helps).
But, this doesn't solve the problem of being global.
You might check the permissions to the folder if you are getting this when creating your project
Express Project
change script section in package.json file like this
"scripts": {
"start": "node app.js"
}
I too faced the similar problem and at last I tried using node.js command prompt instead of windows command prompt and it worked. So, try from node.js command prompt.
Tried all of these but didn't work for me. Also, I tried from different sources but never worked for me.
In the end, found that I need to run the command forcefully. It worked for me.
Make sure you run the command with Run as Administrator.
npm install -g --force express-generator
It will overwrite the existing express files.
Use npm start .. then the app.js runs .. which can be listened on the usual port 3000

Resources