Run npm commandes on cpanel directly - laravel

I just upload script (laravel + vue.js) to CPanel , and every thing works fine,
but i need to make some changes in vue js components.
my question is there any method to run npm commandes directly on cpanel?
npm run dev
npm run watch
i already saw some examples about ssh login key but no solution.

i should return to my project on local and do modifications after that push code again

In Cpanel I found the terminal,
I open it and cd to the laravel project path and run any npm or artisan command,

Related

Laravel runs dev assets nonmatter what on production server after I ran npm run dev accidentally

I ran npm run dev on the server with Laravel 9 using Vite and Tailwind. Now when I run npm run build it is still trying to load the css and javascript files from a domain 127.0.0.1. I can not get it back to reading the manifest.json in the build folder and loading those files.
npm run build runs without any errors,
however the npm run dev was throwing errors and I killed the process and double cheked using ps aux, and pkill commands.
I am lost.
nvm, for some reason the command
pkill npm
does not work I had to use
kill -9 [process-id]
and it worked.

Error on Laravel after installing VueJS. Request failed with status 404

I am developing a small system with Laravel Framework 5.6.39 and everything was going well, until I installed Vue Js. When viewing in the browser, what should be displayed does not appear and the following appears in the console:
How can I solve this error?
I think you need to run:
npm run watch
After adding VueJS to your project you need to install all dependencies by executing:
npm install
Then you can either compile your assets onetime by executing:
npm run dev
Or start a watcher which compiles your assets automatically after detecting a filechange:
npm run watch
The compile process will generate the app.js file which is missing in your case. You can read more about this process or possibilities in laravel here (laravel docs about frontend).
After pulling your project you need to install all dependencies using
npm i
Then you can build it for development one-time using
npm run dev
Or for real-time updates
npm run watch
And when your project is ready for production
npm run prod

I am using Putty to run and compile vue js + laravel app on Godaddy VPS. Changes are not taking effect

I am using Putty to run and compile vue js + laravel app on Godaddy VPS. Changes are not taking effect.
I have Laravel + Vue.js App on VPS.
When I make changes in code, I am running following command in Putty.
npm run dev
npm run watch
Changes are not being applied. Even when it shows all modules built successfully.
npm run watch should apply changes in code.
In local environment using wamp it works
oh, have you tried laravel cached views clear??
php artisan cache:clear

laravel mix not working and my localhost:8000 not work

I create a laravel project with vue js. At first I have created laravel new project and then command npm install. and then command npm run dev
When I command in windows powershell: npm run watch
then whole things are compiled and then When I change somehing in app.js in laravel project and save this file. There is no notice about laravel mix. Besides When I write in my web browser: localhost:8000
I can't see my project. I can see a error message: This site can’t be reached
How can I solve this problem.

Laravel project auto refresh after changes

Does anyone know if there is a way to run the code changes in a Laravel project without refreshing the page every time.
I know that to see the changes I need to
php artisan serve
but I do it every time and it is kind of frustrating.
Thank you anyways.
You can achieve this with Laravel Mix.
According to this part of the documentation, you need to edit your webpack.mix.js file, and add this to the end:
mix.browserSync('127.0.0.1:8000');
It needs to match to the output of the php artisan serve command, where you found a line something like this:
Laravel development server started: <http://127.0.0.1:8000>
After this, you have to run the php artisan serve, and the npm run watch command simultaneously. You must leave to run both commands while you edit your files.
Note: The first time you run the npm run watch, it installs additional components. But the command output is quite clear on that. If everything is in order, Laravel Mix automatically opens your browser with http://localhost:3000, or something like this.
add in webpack.mix.js file in laravel
mix.browserSync('127.0.0.1:8000');
then run this command
> npm install browser-sync browser-sync-webpack-plugin#2.0.1 --save-dev --production=false
after this run npm run watch
> Browsersync automatic run your port 3000
First make sure you install nodejs, After that install laravel-mix
npm install --save-dev laravel-mix
create webpack.mix.js file in root folder for your project and add to it
const mix =require('laravel-mix')
mix.browserSync('127.0.0.1:8000');
Open package.json file and add to script section:
"scripts": {
"watch": "mix watch"
}
Run laravel project
php artisan serve
To update laravel project auto when you make changes run in another terminal:
npm run watch
Updated from Laravel 9.x
you can use vite instead of laravel-mix, you should run this command to install vite:
npm install
Without any configuration, The next line of code will include auto in master page, If you want to include in another master page like admin, you can write it to auto refresh when make changes:
#vite(['resources/sass/app.scss', 'resources/js/app.js'])
After installing vite, run this command
npm run dev
And run
php artisan serve
For more information, view docs
To achieve this you can use Laravel Mix
Ensure that Node.js and NPM are installed:
run node -v and npm -v.
Install Laravel Mix
npm install.
Install browser-sync and browser-sync-webpack-plugin
npm install browser-sync browser-sync-webpack-plugin --save-dev --production=false
Open webpack.mix.js and add this line
mix.browserSync('127.0.0.1:8000');.
Run Project with these two commands: The npm run watch command will continue running in your terminal and watch all relevant CSS and JavaScript files for changes. Webpack will automatically recompile your assets when it detects a change
php artisan serve. and then npm run watch.

Resources