Laravel vue js npm run watch works only one time - node.js

I'm developing laravel vue project.And i am using homestead for development. when i run
npm run watch
it only executes once and not executing when i do changes on my code and refresh the browser.
I tried --watch--poll also. but works only once.
Is there any commands that i can use to automatically compile the code each time when i make changes to the code or any solutions for this matter?

Found out the issue. need to run it outside the homestead environment.

Related

Browsersync no longer works

I'm learning Laravel in combination with Vue and I installed Browsersync to make the process smoother. When I first installed it worked flawlessly.
My setup is the following:
Browsersync installed locally with npm i browser-sync --save-dev
Project location: C:\WEB\project_folder\
php -S localhost:8000 -t public to serve the app. If I go to localhost:8000 it works as expected
added mix.browserSync({proxy: 'localhost:8000', browser: "C:\\Program Files (x86)\\Google\\Chrome Beta\\Application\\chrome.exe", notify: false}); in webpack.mix.js
npm run watch to build and run Browsersync
Strange thing is that the Browsersync UI works properly if I acces localhost:3001, even from another device in the network.
I observed it wasn't working anymore while creating another project where I use Parcel for bundling instead of webpack/laravel-mix. There I use the Browsersync CLI, running .\node_modules\.bin\browser-sync start --proxy localhost:8000 --no-notify --cwd 'C:\WEB\project_folder' -f 'public'
I did not update Node, npm or the OS in the meantime. The only thing I installed is the game Valorant which has some fancy anti cheat service that is installed, but I disabled that service.
I tried:
multiple browsers and devices
switching the order in which I start the server and Browsersync
the development folder was on another partition and I recently moved it to C: so I tried moving the project in the previous location
thinking really hard about the meaning of life :)
I guess next time I will use Docker to have a isolated environment.
I'm stumped. Any ideas? Have anyone encountered and solved this?
This was possibly caused by Windows. I've installed kb4571744 and everything works again.

Create-react-app npm run build too slow

I am relatively new to using React and am following create-react-app tutorials. I am creating a simple webchat service using socket.io, React, and Express in a Node environment.
I've finished writing the majority of the features for the React app and am now working on the server end to connect the apps via Socket.io. Working on the front-end was each because I could just run "npm start" to serve a dev version of my app. However, now that I am working on the server side, implementing Socket.io, whenever I find an issue on the front-end, I have to rerun "npm run build" which takes ~15-30 seconds each time.
I am sure there is a faster way to debug issues like this without having to compile my react app into static files every time. Please advise.
You should run the front end using npm command on cmd panel npm start and debug the backend server side using VSCode Debugger using the node js extension. This way you can run both on dev easily. Plus it give you advance debugging features.

Issue with Node-based Cordova Hook

I'm playing around with the Cordova hooks capabilities and I'm trying to test using a node application as a hook. In this article: http://devgirl.org/2013/11/12/three-hooks-your-cordovaphonegap-project-needs/ it references running node applications, so I know it's possible.
I've created a simple node application that I'm using to test the before prepare and after prepare process:
#! /usr/bin/env node
console.log("this is a node module");
When I run my prepare, I get the following error:
C:\Users\jwargo\dev\lunchmenu>cordova prepare
The system cannot find the path specified.
Hook failed with error code 1: C:\Users\jwargo\dev\lunchmenu\hooks\before_prepare\test.js
I can't find any information anywhere about what an error code of 1 means here.
I've tested the node code and it runs fine with "node test.js" and when I execute test.js from the command line Windows simply launches my default editor.
So, can anyone tell me what I'm doing wrong or what I need to do to be able to execute a node application as a hook with the Cordova CLI?
Figured it out with some help from the Cordova dev team. The space in my shebang was causing the problem. I removed it and the problem went away.

heroku running gulp build

i am trying to install a node app onto heroku. My application requires both gulp build and gulp install to be called on the server upon instillation, however i am having troubles doing this.
I have tried writing this inside of the package.json:
"scripts":"gulp build && gulp install"
which works at first, but after about an hour the server must restart and recall the script causing for the contents of the server to be rebuilt. this removes all of my content such as newly written blogs or changes.
I have also tried using the heroku toolbelt
heroku run gulp build
heroku run gulp install
However, even though it produces the correct console write lines and looks asif it has made the necessary changes, it hasn't, the server produces an error which proves that the resources haven't been built meaning that the console command didnt make any changes to the actual server files.
Am i missing something out here? Thanks in advance.
So i have figured out that the problem lies with the fact that i have tried to use a LevelDB database on heroku. Apparently, heroku uses no-writable dynos, meaning that the levelDB database is unable to save.

How to edit and deploy code without restarting server?

I have node server which i run using forever. But each time if I edit my code I'll have to restart the server. I came across the module called hotnode which can perform live edits but will it have the same performance as the forever module or can I run my code using both the modules. I am confused. Any help wil be much helpful
Have a look at nodemon.
nodemon will watch the files in the directory that nodemon was started, and if they change, it will automatically restart your node application.
As an alternative to nodemon you can use node-supervisor.
I used to use nodemon, but for some reason it didn't detect code changes on my linux box, which supervisor did flawlessly.
The downside is that it doesn't (or at least didn't) give the colorful output nodemon gives.

Resources