GitBash - can't enter a new command after starting npm - node.js

The solution to my problem may be simple but since I'm a beginner on command line and npm it's been hard to solve it by myself, hopefuly you know the solution:
I cloned a repository and then started npm in the command line. After I enter the command 'start npm', it shows in console that webpack was succesfuly compiled but after no matter what I input, the command line does not execute anything neither shows an error message. I've tried to input, as I've done before, a new command but it seems to add text and not a command. (see the picture)
Or if it is not a problem and i'm just misunderstanding something, please tell me.

After I enter the command 'start npm'
Judging by the image you provided, this command is starting the Webpack dev-server. This is a web server for testing your application, which will monitor your files and rebuild your app when any changes are detected. Once the server is running in a terminal, any further input on your part will be ignored. You can stop the server using Ctrl + C.
Or if it is not a problem and I'm just misunderstanding something, please tell me.
The server instance will (in its default configuration) be listening for connections from localhost on port 8080, so (depending on how your app is set up), it might now be enough to visit http://localhost:3000 in your browser to see your project running. If that's not the case, check the output in the terminal window for something like: Project is running at http://localhost:3035/
It might also help to have a look in package.json to see what else (if anything) npm start is doing.
Further reading: https://github.com/webpack/webpack-dev-server

Related

Unable to run node from git bash

I am no longer able to run node from the git bash terminal. It works from Git CMD and the standard windows CLI. If I try to run a file (e.g. node index.js) or even just start node via node, I go back to the input prompt except now I can't see any of my character inputs.
This is not a result of PATH not being set, as where node gives me C:\Program Files\nodejs\node.exe and which node gives me /c/Program Files/nodejs/node and echo $PATH does have /c/Program Files/nodejs included.
If I type another command (such as ls), it actually will work even though I will continue to not be able to see my input.
I think this problem arose after the latest Windows 10 OS update was pushed to my system (10.0.17763). I've tried reinstalling Git for Windows and Node, and neither have resolved the issue. I can't find any other settings that might be affecting this.
Using Git CMD or Windows CLI is a workaround, but neither of those have a "Git Bash Here" option, which is the #1 thing I want this for. It is also nice that I get the visual indication of branch in Git Bash where I do not get that with Git CMD or the Windows CLI.
I don't need or want to use Git GUI, and besides that won't allow me to run local node files which I need to do for testing.
Does anyone have any ideas on how I can get Git Bash working with node again?
UPDATE: By running stty -a after node fails, I see that echo has flipped to -echo, which is why I can't see the input anymore. But that doesn't explain why node isn't loading and echo is getting turned off. Hoping that gives someone some additional context to figure out what's going on here. brkint, icrnl, ixon, opost, isig, and icanon are also getting flipped to the - versions after attempting to run node.
There are 2 possible workarounds (based on what your problem is) that I have tried-
Enter node first of all:
1) Try typing in reset and hit enter. You may not be able to see the input logging in, in the bash terminal window, but it works after that.
2) Or try typing any random alphabet and hit enter(again you won't see it on the screen),it will throw a 'command not found' error but you will have node working after this.
I am afraid these aren't exactly proper fixes, but they get the job done.
More information can be found here: https://askubuntu.com/questions/171449/shell-does-not-show-typed-in-commands-reset-works-but-what-happened/172747#172747

Missing file or plugin on freshly installed Cloud9 ide?

I'm currently trying to set up cloud9 on my debian server for node.js development. I followed some simple steps as described below, but there seems to be missing something and I would like to know how this can be resolved in the best way. Of course, I could start looking for the missing file on the web and put it there, but I think that's not the way to go.
What I did is this:
ssh'ed into my Debian server into my home folder
sudo git clone https://github.com/c9/core.git sdk (completed succesfully)
cd sdk
sudo ./scripts/install-sdk.sh
The installation finishes like this:
Success!
run 'node server.js -p 8080 -a :' to launch Cloud9
When I then start up the IDE with this command:
node server.js -p 1234 -l 0.0.0.0 -a rob:mypass -w /home/rob/myproject/
...everything looks good:
Starting standalone
Connect server listening at http://x.x.x.x:1234
Using basic authentication
CDN: version standalone initialized /home/rob/sdk/build
Started '/home/rob/sdk/configs/standalone' with config 'standalone'!
Cloud9 is up and running
and I can basically reach the IDE from my local browser. The problem is that it stops on the welcome screen with this loading indicator in the middle right under the cloud9 logo. The JS console shows a missing file (I've replaced my real URL):
http://myserver.de:1234/static/plugins/c9.ide.collab/notifications/bubble.js Failed to load resource: the server responded with a status of 404 (Not Found)
I then looked into the folder /home/rob/sdk/plugins/c9.ide.collab/, but it is empty.
What am I missing? Do I need to install something with npm or do I have to change the package.json file somehow? I'd really appreciate some help because I think wildly modifying and copying in files won't make things better.
edit: It turns out it was "bug in the script updating references [of some plugins]". Details: https://github.com/c9/core/pull/365
—Cheers!
Original answer:
I think think the c9.ide.collab plugin's refspec is wrong here: https://github.com/z3cka/core/commit/5f45ea38f422160a0030c5ef8d1efb19231bc78c#diff-b9cfc7f2cdf78a7f4b91a753d10865a2
I changed it back to #54aa1cbee0, ran the install-sdk.sh and it grabbed the latest version of the collab plugin. While prepping a PR, I just found 3 more plugins with bad refspecs
c9.ide.language
c9.ide.language.javascript.eslint
c9.ide.run.debug
I'm currently working on a fix for the rest of these.

Node http-server persists port 8080 even after they were close

First, this is my configuration:
Windows 7 Professional
Node v0.12.2
NPM v2.7.4
http-server v0.8.0
I've installed http-server using npm install http-server -g, still on terminal, gone to my root folder ...\node\teste and executed http-server -a127.0.0.1 -p8080. Until this part everything seemed ok. The server was up and running.
When I accessed the url localhost:8080, it gave me a download file back as an answer, my index.js.
Shutdown the server with CTRL+C at the terminal, made some changes in file, up the server again and a download file as response again, but not the actual file it was the first one I've downloaded and deleted.
So, I've changed my original file name, stopped the http-server function, cleared the ports so that was not shown in netstat -a -b and I can still access localhost:8080 and download the file. Even restarting my PC.
There is no node process running, I've checked.
After all that effort, which can be considered part of the sollution, I finally found what as the last piece of the puzzle.
I've gone to my broswer(Google Chrome) and oppened:
Settings > Advanced Settings > Privacity > Clear Data
And cleared all my broser data.
Then localhost:8080 is free now.
Wanted to share this information so nobody will lost hours, like me, trying to find answers.

node.js command prompt not initialised as expected

I installed the .msi file from nodejs website and installed it.
Now, when I run nodejs.exe, I do get a command prompt, but it shows a blinking > by default, instead of C:/>
It looks somewhat like this:
What to do?
This is called the REPL. You can enter statements for Node to execute and get realtime feedback. Ctrl+C twice will get you back to the command prompt.
I recommend checking out the answers to How do I get started with Node.js for learning more about Node.js and how it works. Typically you provide a file with your Javascript for Node to execute:
node app.js
or you can leave the .js off:
node app

running a server file on node.js

I've been practicing with "hello world" examples of websockets and node.js server.
According to all those examples you create a html file (client) and a js file (server).
Before you run them, you have to run this on the command line (I use windows)
node nameOFtheServer.js
So, my question. If I close the command line window and open it again the client does not connect to the server. I have to run again the above code in the command line , manually, so the server will start again. Why is this happening? Is that normal? How can I fix it , so I dont have to run the same commands over and over again on the command line in order to start the js file (server) ?
Thanks
EDIT
OK, new facts, I just edited the question, highlighting the changes in Italics
When you close the terminal, everything that runs in it is killed. There are many solutions on both Linux and Windows systems, most of them create some sort of a service which then runs in the background.
Here are some possible solutions:
http://blog.nodejitsu.com/keep-a-nodejs-server-up-with-forever
https://github.com/indexzero/daemon.node
http://www.coretechnologies.com/products/AlwaysUp/Apps/RunNodeJSAsAService.html
http://coreybutler.github.io/node-windows/manual/#!/api/nodewindows.Service
Pick the one that is best for you.
Related question on StackOverflow:
How to run node.js app forever when console is closed?
First of all thanks Venemo for your anser. I tried use the forever module, but did not worked well, as you can see here.
So I decided to use nssm with node.js
I download the nssm and unzip it in the C:Program Files\path\to\nodejs. And then I opened Window's command window and typed C:\program files\path\to\nssm-2.16\win32 and then typed nssm.exe. You should see a "menu" how to install or remove services. And now type
"C:\Program Files\path\to\nssm.exe" install give-Your-Service-A-Name "C:\path\to\node.exe" \"C:Program Files\nodejs\path\to\yourServerFile.js"
Notice the \ before the "C:Program Files\nodejs\path\to\yourServerFile.js" it's not a typo, you should type it, is important, if you have spaces in your path, helps nssm to interpret correctly.
And that's it, now press CTRL+ALT+DEL, open the Services tab, and find give-Your-Service-A-Name , right click and select Start service. To check, open your client file that communicates with the yourServerFile.js, it should be working, without having to start the yourServerFile.js from command line.
(PS : I use nodejs 0.10.12 and nssm 2.16 on windows 7. The instructions above are a combination of this tutorial and this anser)

Resources