I have written some code that requires moment.js. It works on my local environment. Now i want to push this branch to production using laravel forge / and a git repository. I installed moment.js on my local environment using: npm install momentjs. My question is: will moment.js be available now on production server without me having to add 'npm install' to the laravel forge deployment script and adding momentjs to package.json. The reason i ask this also is because i read running 'npm install' in a deployment script is a no-no. So how do it do this properly?
Related
I am about to finally deploy my laravel app to shared host soon, using ssh. My question here is: in local enviroment I installed all npm dependencies (npm install), to compile all vue.js scripts.
What i already know is that: after uploading everything to shared host I should run "composer install" to install composer dependencies and edit .env.
But should I also run "npm install" if I already have my app.js compiled on local enviroment?
Thanks,
PS
You actually probably don't have npm on a shared server. At least with HostGator, which is where I have experience, it wasn't possible - in which case - you would need to run and compile npm locally before pushing to the server.
Yes as per my experience with Hostinger it is not possible to install NODE, and NPM via a command on the server. Because it is not a private server and it is already given us our requirements setup during server selection. So you can do this by pushing your js assets with git and pulling on the server to get js.
I've created a site using foundation sites. It's using the standard install using the Foundation CLI.
I've got the site running locally using foundation watch. When I push this to Heroku the build succeeds in the Heroku console but when I visit the site in a browser I only get an application error.
Heroku support has said I should be using $PORT in my startup script but I don't know where to configure this. This also seems strange as it's the first install.
Has anyone had similar problems?
Here are some of the issue i find in your app.
Firstly heroku is not going to install any of your devDependencies, so make sure all dependencies required to build are in dependencies list.
Heroku searches for Procfile, which is used to launch app. If it doesnt find that, it will go with standard procedure.
In your case
It runs npm start. Which calls gulp to run build, server and watch( which is not necessary ).
Second heroku assign PORT number dynamically. But your server task binds a static port number 8000 from config.yml. So that may fail your app.
You dont need to use foundation watch in heroku as watch mode of files are not needed
You are required to run a server and server your files
My advice is to use expressJS server( because i have used it ) after your done building your app with gulp
In your start script(package.json), you can write something like
"scripts": {
"start": "gulp && node server.js",
"build": "gulp build --production"
}
where server.js is expressjs server file. here's an example how you can write it.
Hope your problem will have less issues now.
Not to say about your github repo, but here are some points that might helpfull for you as well as for your clients/users or anybody.
Why you have uploaded all node_modules and bower_components to github. When you have their respective json file, anyone can do npm install or bower install to download all required packages.
Uploading node_modules and bower_components will be a headache for you as your push and clone size increases.
I deployed Parse-Server-exemple to Heroku using thee Deploy button, and everything is working fine. (up to the fact that there are some bugs)
But the Parse-Server(https://github.com/ParsePlatform/parse-server)is being updated more frequently and now has lower bugs.
How to deploy Parse-Server on Heroku ?? or at least how to update the server running on my existing Heroku app ?? I can't find the answer anywhere
Parse-server is the nodejs package. you can remove this line here and you can remove the node_modules from .gitignore, then you need to download the "Parse Server" to your node_modles folder and deploy it. but it will be easy if you try to use some service like www.parseground.com
Your starting point should be reading up on how to deploy nodejs apps on heroku. Parse Server is just another npm module. Contrary to #pivanov's answer you should preferably keep node_modules in gitignore and let heroku install the npm packages including Parse Server. This is what heroku recommends in their documentation.
You can clone your parse-apps by running the falling command using the heroku work belt
$ heroku login
$ heroku git:clone -a
Heroku at this point automatically create a git branch 'master' that you can commit to.
You can now make changes to your parse server version depending in the available version.
Current version i think is 2.1.4
"parse-server": "^2.1.4",
You can now commit and push changes to the master branch created.
$ git add .
$ git commit -am "make it better"
$ git push heroku master
You can use
npm update
it will update the parse server if you have used "*" as its version in your package.json file.
Quick explanation: I have a staging and a production server, both with the same deployment script (the only difference is the repo branch the clone). The deployment script runs bower install which is globally installed on both servers.
To install it globally I changed npm config set prefix to /home/forge/.npm-packages and afterwards ran npm install -g bower (note sudo wasn't needed, that's the point of changing the prefix). Once again, this was done in both servers.
When I ssh into each server, and run bower -v, which bower it is clear the command DO exist, and it IS added to PATH env. It is the same output for both servers.
Manually running bower install on the project root works for both server.
The issue is the forge deployment script, which only fails on production (IKR? I don't know what was I expecting).
The actual output is:
/home/forge/.forge/provision-2394191.sh: line 8: bower: command not found
The interesting part is, in my attempt to debug, I manually ran provision-2394191.sh and it worked.
What is wrong with my production server?
Seems like adding the new /home/forge/.npm-packages to the $PATH using export was not enough. To solve this I had to manually add it to the /etc/environment file.
There's always been a note in many Readmes of composer-based projects:
Never run composer update on production server
However, there are times that we want to run composer update on PROD servers to keep current (of course after a thorough test on local server). What's the best way to do that?
You should run on local server.
composer update
Next you should test application and add composer.lock to repository. And on PROD server you should run
composer install
composer update is checking if there are any new versions of the packages available within the limits of the versions given. This will unconditionally install new packages if they are eligible. After that you have to test.
composer install will install whatever is mentioned in the lock file, and if the currently installed packages are not the ones mentioned there, they will get uninstalled or updated.
Of course you want to "update" the prod application. But to update the packages, you run composer install which will update the packages to the TESTED state in the lock file - not to an UNTESTED state because newer versions did appear after you tested.