In Angular 5, after creating project folder, installing Angular CLI, Node.js (all latest versions) and ng serve was compiled successfully through command prompt. Then I tried to use command prompt to install bootstrap. I could not control / use command prompt. What might be the cause and effect?
Command prompt stuck after compilation
There are simple ways:
If you use Command Prompt(Terminal), open another Command Prompt inside your project path.
If you use IDE like Visual Studio Code, open Terminal and then you can use Plus(+) sign for openning anothor Terminal like below image:
If you use IDE like WebStrom (Jetbrains IDE), first open IDE Terminal then make right click and select New Session and new terminal openning like below image:
There are couple of ways you can do that.
The official way of deployment of angular app.
Create a start.bat (if you are using windows) and write the ng serve --open command there. Now you can run this file which will internally run your angular app, using forever or pm2 npm modules.
If you do that these will demonise your process to run in background and your same command prompt becomes usable again.
Once the process is finished( compiled successfully), you would notice that the cmd -prompt newline doesn't show any directory and its blank.
This means that, you just have to open an another (new terminal), get to the right directory using "cd command "and implement your desired commands or operations again.
use ctrl + v it will ask weather to terminate say Y, cursor will go back
Related
I have a question about usage of Nodejs.
I installed it on Win7 and run (green Node.js icon) it, but when I tried to run "npm install" command it dodn't work. I had to move to Nodejs command prompt where npm is working.
Is that how it supposed to work?
Once you install NodeJS under Windows, it goes into the global PATH, meaning that it is available in the usual Windows command prompt. So, just open one by pressing:
Windows+R
Type cmd and press Enter
Then type node -v. You should be able to see an appropriate response.
Add your AppData\Roaming\npm and Program Files\nodejs folder to your path.
Also have a look at this:
Node.js doesn't recognize system path?
Second answer helped me to add my Roaming folder.
I'm trying to learn Node.js. I really like a lot of the ideas I've seen. Currently, I have "Hello, World" working. To run hello world, I simply type node hello.js from a windows command prompt. Now, I'm trying to integrate Node in with Visual Studio as a Tool. Essentially, I want to be able to click the "TOOLS" menu in Visual Studio and choose "Node", and my currently selected file will run in a Node environment.
My question is, how do I do this? Currently, I have the following external tool configured:
Title: &Node
Command: C:\Windows\System32\cmd.exe
Arguments: node $(ItemFileName)
Initial Directory: $(ItemDir)
When I choose "Node" from the "TOOLS" menu, a command prompt window is opened. The directory is set to the directory of the file I've chosen. However, the command "node [filename]" doesn't get executed or entered. What am I doing wrong?
So I replicated the issue you've experienced so I've tried to simply point it to node.exe instead and seems to work pretty well ;)) Will probably end up using this as well!
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)
A simple question: Is it possible to configure the Geany IDE so that Node.js servers can be run directly from Geany using the "Run" button?
When inside a JS file, go to Build > Set Build Commands, there should be a section title Execute commands. To use node to execute your files, put: node "%f" in the "Execute" command textbox.
When you change this, any .js files you are editing will run node in the virtual terminal when you hit F5.
If you want to set up an entire project to run the server whenever you're working somewhere within a given directory structure, you'll have to mess with project-level configuration. (something I don't usually bother with) My solution here just gives you a quick way to execute a single JS file without using an external terminal.
UPDATE: node "%f" seems to be legacy, but nodejs "%f" works
I'm trying to run some nodejs apps in Notepad++. I installed NppExec and node works just fine in the console, but npm packages don't run even though I installed them with the -g flag. My current workaround is to call cmd from the console and then running the app like:
// `cmd` inside Notepad++ console
C:\>lessc "$(FULL_CURRENT_PATH)" > "$(CURRENT_DIRECTORY)\$(NAME_PART).css"
How can I run it straight from the Notepad++ console without having to go into cmd?
Frankly this looks like a bug in NppExec, where it cannot run .cmd files from PATH.
A workaround would be to run:
where lessc
You'll get the path to the command like: C:\Users\username\AppData\Roaming\npm\lessc.cmd
Use that path inside NppExec console.
C:\Users\username\AppData\Roaming\npm\lessc.cmd "$(FULL_CURRENT_PATH)" > "$(CURRENT_DIRECTORY)\$(NAME_PART).css"
However I'd stick to the solution you already found, looks far more better to me.
Know this is old but still appears high up google results.
To run .bat or .cmd you need to add the extension.
npp.cmd start
From Docs Npp_Exec Manual:
The same approach can be used to execute .bat and .cmd files - but the file extension (.bat or .cmd) can not be omitted in this case.
cmd /c cd $(CURRENT_DIRECTORY) & node $(FILE_NAME) & pause