where should I set METEOR_DISABLE_OPTIMISTIC_CACHING - performance

I am totally new to Meteor. I am trying to run Reaction Commerce on my local machine. I found someone pointed that set METEOR_DISABLE_OPTIMISTIC_CACHING = 1 can speed up the meteor loading time. However, I don't know how to set this thing up on Window 10.
Does anyone know about this?

METEOR_DISABLE_OPTIMISTIC_CACHING is an environment variable.
You can set it in three ways:
system-wide in control panel
for a specific shell by using SET METEOR_DISABLE_OPTIMISTIC_CACHING=1 in a command prompt before running meteor. Easiest to use in a .bat file
in an npm script using the cross-env package
I recommend using cross-env. First meteor npm install --save cross-env
Then add a start script to package.json:
"scripts": {
"start": "cross-env METEOR_DISABLE_OPTIMISTIC_CACHING=1 meteor run"
}
now when you run npm start it will set the environment variable just for that one running instance of meteor

Related

"NPM install" command line cannot run in LARAVEL project directory

I want to work with webpack and Laravel
I'm trying to install Mix in my Laravel project.
So i have installed node and npm succesfully.
When i run node -v and npm -v in vscode it show me the version number so i think the install is ok.
But when i go in the Laravel project directory and try to run "npm -v" or "npm install" i have a message like "npm: The term 'npm' is not recognized as the name of cmdlet, function, file
script or executable program"...
Did i do something wrong?
My bad...
I had another session of Vscode runnign on the other screen and i didnt see it.
I closed all vscode session and reboot and it work
Thank you very much!

Running artisan commands along with npm commands

I am trying to find a simple way to run npm dev and php artisan serve using a single command. I have created a new script within package.json and run the command via npm run start. This may come as obvious to most, but I thought it was an interesting idea that obviously can be expanded upon.
Here is the command below in case anyone has this idea down the road and doesn't want to spend an hour looking into it like I did.
"scripts": {
"start": "(php artisan serve) & npm run dev"
}

It's possible auto load or livereload npm run dev

I want to know if exist some way to live reload or autorun the npm run dev command without type in the shell npm run dev
When i use VueComponents in Laravel with Webpack Mix, for every change in code i need run npm run dev and that proccess is delayed a lot
In the past, i did use ionic, and when i had saved a change the pack is live reload and had build without type nothing in the shell
Thanks!
Try running this command:
npm run watch
or
npm run watch-poll
When you create new component/js file and attach it to Webpack
Mix then you need to run
npm run dev
Real-time monitor the changes and compile them
npm run watch
For production mode run
npm run production
To go back to development mode
npm run development

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.

How can I run npm install as part of an Octopus Deploy?

After I've deployed my nodejs website, but before I update the IIS virtual directory, I need to execute npm install from the command line.
How can I do this with Octopus Deploy's scripts feature?
Either add a PreDeploy script with the command you want to run in your package or via the UI
I've marked Robert's answer as the correct one as the high-level approach is the one I needed. For the record here's the PowerShell script I used-
$installDirectory = $OctopusParameters['Octopus.Action.Package.CustomInstallationDirectory']
cd $installDirectory
npm install --silent

Resources