Angular 8 Universal - server.js file size issue while making a server build - angular-universal

When I'm making a server build Webpack every time just adds the server part into the existing server.js file under my dist folder.
Say, the file size is 14MB, after executing the build:ssr command the files size will be 28MB and so on. Then I'm trying to execute server:ssr command and it's showing up the error that the port 4000 is already in use. I think that there are duplicates in the newly created server.js file.
In order to have it working I have to prepare a new empty server.js file. Then it creates a working server.js file with a small size.
How to fix the issue?

Related

Changes in the vue file not applying in the browser

I am working in project having technology(laravel + vuejs).In that there is a form created in vue file and i want to add a text in the vue file.So as i have seen that "when any changes is done in vue file then need to rebuild the application".And i see that there are commands for rebuild the application is npm run dev , npm run prod , npm run watch and npm run watch-poll. I have tried all this commands after saving the file through FTP but sometimes the changes is applied (Note : Not immediately but after some duration) and sometimes no changes apply in the browser.When i tried the above command by executing it then there is no such error occurs and the rebuild is done successfully.So what will be the issue can you please suggest something that i need to configure?
Below is the code of package.json,webpack.mix.js file and after that i have attached image of putty in which application rebuild is done.
Thanks in advance!
I think you are not understanding what npm run dev/prod/watch do. If you alter the .vue file in your resources folder, then have npm rebuild your assets, then ftp the vue file to your server, nothing should happen.
Depending on how you have your laravel mix file set-up, the file you need to ftp to the server is likely public/js/app.js.
You should really consider getting your local environment setup for development, there is nothing I can image worse than viewing your changes by ftp-ing files to a server.

Angular Console: Can't create library

I'm trying to create a new library using v 8.1.0 of the Angular Console on Windows. The error I get is "ENOENT: no such file or directory, mkdir "c:\path\to\my\workspace\libs\new_library_name"
"c:\path\to\my\workspace\libs" exists already
new_library_name folder should be created by Angular Console
The command run by the console is ng generate #nrwl/angular:library new_library_name.
I've tried different names/paths, running as administrator, running inside VSCode and in the standalone console. No luck with anything. This used to work.
Also, if I create the folder c:\path\to\my\workspace\libs\new_library_name and then run the console again, I get an error ENOENT: no such file or directory c:\path\to\my\workspace\libs\new_library_name\ReadMe.md. Of course the ReadMe doesn't exist - it needs to be created by the console.
What am I doing wrong or where to look?
Problem solved. I had turned on Controlled Folder Access in Windows 10 and mistakenly included my project folder as a controlled folder, which prevented applications (Angular Console, Yarn, etc) from writing to the folder. Removed it from Controlled Access and all is working again.

Laravel application deployed to AWS Elastic Beanstalk shows file not found error

I'm using AWS EB to host my Laravel 5.8 application. I have a view where I upload files. These files are 2 CSV files and a ZIP archive. Long story short, these files are stored locally to process their content, once they are stored, their stored location, which is returned as temp/... is concatenated with the helper method storage_path() to determine the full path for the file to open for processing:
$file = file(storage_path() . '\app/' . $filePath);
Once this line is reached, I'm getting this error:
fopen(/var/app/current/storage\app/temp/routes/20190906143753/ztySdkFwY5bAvQhIK4Mlsftz8fzVJfPK3S3d5CSV.txt): failed to open stream: No such file or directory
*************** UPDATE ***************
So it turns out that the storage folder in my Laravel project had no write permission. I've managed to fix that and now the files are actually being stored. However, another problem showed up. Which is files aren't stored fully until the execution of the page ends, which is not what I want since those files are also used during the same process for other purposes.

How to host a simple index.html with some javascript and css on Heroku?

I'm trying to deploy an application through Heroku which is just an index.html page with some javascript and css.
I've connected my Github repository to it as a deployment method, but it never seems to work.
Every time I type "heroku logs", it spits back out:
"npm ERR! missing script: start" first.
From what I've searched, it tells me that I need to add "start": "somefile.js" as a starting point in package.json, but this is a very simple index.html page with javascript invoked from whenever a couple buttons are pressed.
How am I meant to get past this?
Heroku isn't really built for hosting static websites that have no dynamic server backend. If you want to do that, you should look into using a proper static file host like Amazon S3, Netlify, etc.
However -- if you DO want to do this on Heroku, you can do so by creating a really simple application (here's an article which shows you how to do it using Ruby): https://devcenter.heroku.com/articles/static-sites-ruby
Agree with #rdegges, you need some sort of http server. A basic node http server is pretty trivial to implement as well.
A full tutorial is available, but the keys steps are:
Make sure you have [node, npm, heroku CLI] installed.
In the root of your project directory, run npm init - (this will create a package.json in your root project directory)
Run npm install --save express - (this will add express as a dependency to the package.json file)
Create a file named Procfile in the root directory.
(contents: web: npm app.js)
Create a file named app.js in the root directory. (contents below)
Commit your changes, push to Heroku - git push heroku master
That should do it. Make sure all your files are in a directory called public as specified in the app.js file or change that to reflect where they actually are.
app.js:
var express = require('express');
var app = express();
app.use('/', express.static('public'));
app.listen(process.env.PORT || 8080);
Full Tutorial: https://devcenter.heroku.com/articles/getting-started-with-nodejs#introduction

Tool for Windows that can watch a directory for source code changes and then redeploy server?

Right now I'm having to save my code on local machine, quit node.js server, and restart it to see the changes. What would be great is if I could make it reboot so that whenever I click save on my favorite editor, it will automatically start the restart sequence and load the page on my web browser. Can grunt achieve this?
You could use the "up" tool it'll watch a dir for changes and reboot when it finds them.
On the command line run:
npm install -g up
Then you can use it to start your node app:
up -w -t 500ms -n 1 -p 3000 server.js
where the server.js file is a file that exports your http server
See the "Setup" section in the following link to export your server:
https://github.com/LearnBoost/up/
You don't really want to work that way. Instead setup a version control system (SVN, git, or whatever suits you) then set it up, so that the code is deployed only after you actually commit the code. You don't want to restart your server on every file save, as this will slow you down considerably (and will also result in pushing a lot of buggy code to the server).

Resources