Does angular run on node server?
If yes then does ng serve run node server or angular server?
If it runs node server then can I upload file on this node server using angular?
My actual requirement is to edit a file (say en.json) in my project using angular. Can I do that just using the angular server because it runs on node?
First of all, Angular isn't a 'server'. It's a framework. If you're talking about specific CLIs, running ng serve will start a Node server, it's all in their documentation, clear as day. Anyways, you shouldn't even try editing files using Angular, you can make http requests towards an endpoint via Angular and make your NodeJS server edit that specific file on your back-end. For uploading files check this npm package out, I've personally used it numerous times while I worked with Angular.
Related
I have created an API project with NodeJS and Express. Now I want to build the project and publish it to my IIS Server. Can someone guide me in the correct direction ?
You don't need to build a node.js app. You just need to run it with node.
eg node ./index.js
You don't need a web server to run a node.js app. Node is a server.
You can't build a node application, node is a server, you run it by running the index file, for production you simply run it and flag it as production.
This might help Hosting express node.js applications in IIS using iisnode. For more info on the project itself, you can find its repo here iisnode.
I had made an web app using React, Node and MySQL. When I am packing this app for a client I am deleting the node modules, env files etc. And when the client gets it he has to run some commands to use this app like npm install in both react and node folder etc. So I am little curious, do we have any third party software which can help me to make a wizard to install the project and run it? Or how can we do it? I saw some PHP application had done this.
I'm new in Angular and NodeJS. I finished all the basic documentation, and now I'm doing tutorials. My question is about the architecture.
Following the angular tutorial, you create a new server:
ng new new-project
That creates a whole server listening to port 4200, you learn and work with angular, learn about directives, etc.
Then you create a server with node, configure routes, etc.
But how these two servers live together?
What do you recommend me to join them?
This is a node server. The angular part are just two files
This is the server created with ng serve. The angular part is so much complicated
Angular project is not a server. Angular is framework to create front-end page/app. Angular-cli command ng serve is used to build application and start a web server on localhost.
When you build your page with angular use angular-cli command ng build --prod to build your page ( more info about ng build command). The build artifacts will be stored in the dist/ directory of your project.
If you want to host angular page with node - copy file from projektFolder/dist to catalog when node can have access to copy files. In node you can use express library to host static files:
app.use('/myangularproject', express.static('myangularproject')) //host static files`
More info about hosted static files in node and express
EDIT
You use Angular CLI to build an angular application. This is an additional tool for working with angular and you do not have to use it.
Angular cli is a command line interface to scaffold and build angular apps using nodejs style (commonJs) modules. Not only it provides you scalable project structure, instead it handles all common tedious tasks for you out of the box
ng serve
ng serve is a tool from angular cli. When you call this command your project is build in memory and serve it via webpack-dev-server. It is used for quick preview and development of the project. If this command is confusing for you then you can use the npm script npm start.
The CLI supports running a live browser reload experience to users by running ng serve. This will compile the application upon file saves and reload the browser with the newly compiled application. This is done by hosting the application in memory and serving it via webpack-dev-server. doc
ng build
ng build compiles the application into an output directory.
Compiles an Angular app into an output directory named dist/ at the given output path. Must be executed from within a workspace directory.
When you use command ng new Angular CLI add all necessary files to develop your application. Some of them are used to configure the project e.g tslint.json, tsconfig.json, angular.json ... Do not host these files only result files from the use of the ng build command (/dist directory).
Angular CLI compiles your project into several files (try ng build and look how many files do you have in /dist. You must host all of them. These are static files. You do not need a special server like php files. You can host them using a regular file server. I don't know what you concern use in the node to host static files. If they use express you can use express.static(). More info at the top.
This question already has answers here:
Which command do I use to generate the build of a Vue app?
(19 answers)
Closed 4 years ago.
I think I have a bit of a mess here. I have my vue app running in my localhost environment. I want to deploy to a server I have hired. Which are the steps to accomplish this?
I have installed nodejs and npm on the server. At a first glance I tried to go the way I always did when using php, running nodejs app through apache server but it seems it is not the best option from what I read. In my local machine I run:
npm run serve
to start a server to run my vue app locally. Should I do same thing on my remote server? Are there better options?
Should I do same thing on my remote server?
Definitely no.
Notice in your package.json file you should have a script called "build", i.e. you can execute it with the command:
$ npm run build
Once executed, it should compile your Vue project and place the resulting files in a dist folder at the root of your project.
Notice that these files are plain HTML, JS (for browser, since Vue is only for front end) and CSS (plus any of your project assets if applicable).
Since you are familiar with PHP, you should know what to do with those files. Should your project be "simple" and not require backend services (like AJAX, REST, etc.), you can actually serve them on a simple server (no need for PHP, Node, etc.).
Otherwise, you should have plenty tutorials and resources online explaining how to publish those files on a simple server.
I've finish building rest API using sails.js. I would like to deploy this build to the server. However, I just feel that it doesn't make sense to be uploading the plain js files from the current directory to the server. Are there ways to compile all the js in API and config folder in a smaller package just like what webpack did for assets folder so that it will run on browser without running command node app.js
Is it normal to just copy the js files to server and run node app.js to start the application?