Vite manifest not found - php

I Working on project that working with laravel 9 and Vite with laravel-vite,
In Dev environment all thing working fine, but in production cPanel server I has this issue
Vite manifest not found at: /home/???????/cart_shop/public/build/manifest.json
# With
Missing Vite Manifest File
Did you forget to run `npm install && npm run dev`?
I tried to solve the problem but nothing work, I need to change the public folder and the sup folder build file place from vite.config.js but I don't find the way to do that.
Note that: the file sequence is changed in cPanel shared server from
- home
- public_html
- cart_shop
- Root
- public
- etc
To
- home
- public_html
- public files and folders // I changed the index URLs too.
- cart_shop
- Root
- etc
my vite.config.js config is like:
import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
import vue from '#vitejs/plugin-vue';
export default defineConfig({
plugins: [
laravel({
input: 'resources/js/app.js',
}),
vue({
template: {
transformAssetUrls: {
base: null,
includeAbsolute: false,
},
},
}),
],
});

I had the same issue only because of node version. I upgraded to the latest version and it's working properly.
For Ubuntu use n module from npm in order to upgrade node:
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
To upgrade to latest version (and not current stable) version, you can use:
sudo n latest
You may need also to Fix PATH:
sudo apt-get install --reinstall nodejs-legacy # fix /usr/bin/node
To undo:
sudo n rm 6.0.0 # replace number with version of Node that was installed
sudo npm uninstall -g n
You may need to restart your terminal to see the updated node version.
Found in Ask Ubuntu

Type this it's works for me
npm run build

In my case, I have solved this problem by doing some things.
First of all, I have installed npm by running this command
npm install
After that, I have run
npm run dev
And finally, I have run
npm run build
And one thing I have noticed is my problem is not solved somehow and for that, i have run some command,
php artisan optimize:clear
and after running this command I have run those commands that i have run previously
And finally my problem is solved.

Update Node.js to its latest version: https://nodejs.org/en/
Then run npm run dev.

Remove #vite(['resources/sass/app.scss', 'resources/js/app.js']) from the <head> of the file app.blade.php on Laravel 9. And now it works like a charm.

The issue solved,
first: I try adding publicDirectory configration into laravel-vite-plugin setting in vite.config.js that solve the build issue but manifest still not founded.
Finally: I move all files and folders except build from public to bublic_html then npm run build and it's working fine.

just go to your public folder and there is a hot file in that file there is a link like this http://127.0.0.1:3000 change this link to your domain link i mean your website link

If the manifest.json file does exist but you're still seeing this error, make sure the permissions are good:
sudo chown www-data:www-data -R public/build/
sudo chmod g+w -R public/build/

I had a similar problem and I was able to resolve it by installing the node current stable version. In my case, the node version was 14+, and when I upgraded to the current version which is v16.17.0, everything works just fine. The comments here were helpful.
Visit the official node website to download and install the latest node version.

I solved this problem like this:
npm run build
When you put public files inside public_html. Create a public file in the root of the domain and put the build folder inside it And it was done.

Initially, this is your configurations in the package.json file, You can change the settings in your scripts or just run the vite build command on the terminal.

Related

Symfony 6 AWS Beanstalk run npm run build

I'm new to AWS and I've gotten as far as getting the following error in Symfony:
Asset manifest file "/var/app/current/public/build/manifest.json" does not exist.
In local, this would be fixed by running npm run build. I've tried adding NPM_CONFIG_PRODUCTION=true in the environment variables, but I think that might just be for node.js apps?
I've also tried SSHing onto the EC2 instance and installing node on there, but I ran into errors trying to install either npm or nvm. I feel like this is the wrong approach anyway, since it seems like the idea of beanstalk is that you shouldn't need to ssh onto the instance.
Perhaps I should just include the node_modules folder in the zip uploaded, but since one of the recommended ways to produce the zip is to use git, this doesn't seem correct either.
After a lot of digging around, it seems like there's 3 options here:
SSH onto the instance(s) and the following worked for me (Amazon Linux 2 - ARM chip)
curl --silent --location https://rpm.nodesource.com/setup_16.x | sudo bash -
sudo yum -y install nodejs
(cd /var/app/current/;sudo npm add --dev #symfony/webpack-encore)
(cd /var/app/current/;sudo npm install)
(cd /var/app/current/;sudo npm run build)
The problem with this, is if you have multiple instances that scale up and down with a load balancer, it isn't really practical to do this.
Add the above as a hook:
The following sh file could be put in the following directory: .platform/hooks/predeploy
#!/bin/bash
curl --silent --location https://rpm.nodesource.com/setup_16.x | sudo bash -
sudo yum -y install nodejs
(cd /var/app/current/;sudo npm add --dev #symfony/webpack-encore)
(cd /var/app/current/;sudo npm install)
(cd /var/app/current/;sudo npm run build)
However, I've since learnt that it's best advised to just include the node_modules in the zip that gets uploaded. I guess this way the time to get the server up is reduced.
Include the node_modules folder in the zip that gets uploaded.
To include the node_modules folder, since this is naturally ignored by GIT, I used the EB CLI and added a .ebignore file, which is a clone of the .gitignore file, but includes the node_modules and public folders. Also be cautious in your build process that you're not including the node dev dependencies.

-bash: laravel: command not found - Mac High Siera

I've installed a fresh copy of High Sierra today (After resetting my whole mac) so now I am at the point of installing all things related to programming, like the Laravel installer for now.
I have problems with installing the laravel installer and with the path I suppose.
I know there are a lot of questions a bit similiar to this but for some reason I haven't found the right answer yet.
So as the documentation of Laravel said I installed composer and that works just fine. After that I installed the Laravel installer with composer. I placed the command(?) for my path in the .bashrc file but after a re open of my terminal the command Laravel was not found. I knew from previous times this thing was a pain in the ass and I am also not very familiar with all those things in the command line so this is kinda hard for me.
What I did:
1) I installed composer. After that, I did mv composer.phar /usr/local/bin/composer in my terminal. Also I did mkdir -p /usr/local/bin because i had a fresh install so those directories were not found of course, because they didn't exist.
2) After that I ran composer global require "laravel/installer" in my terminal. This was all going great.
3) Last step was to do this thing with the PATH. I still don't know if I did this right. What I did was nano ~/.bashrc and then added export PATH=~/.composer/vendor/bin:$PATH to this file. This did not work, so I still can't use Laravel .. in my terminal. I don't know much about this source command but when I do source ~/.bashrc I can use this Laravel command but when I open a new tab or window I can't use it anymore.
4) Besides export PATH=~/.composer/vendor/bin:$PATH in the .bashrc file I also tried export PATH="$HOME/.composer/vendor/bin:$PATH" in that file. that doesn't work either.
Is there someone that can help me out? Good to know is that I just installed a fresh copy of OS and did nothing besides installing some normal programms. Laravel/Composer were my first things with the terminal.
It might be that your terminal program is set to create a login shell, which doesn't source ~/.bashrc
Try adding this to ~/.bash_profile
[[ -f ~/.bashrc ]] && . ~/.bashrc

How can I composer update on OpenShift?

I am trying to use Slim on OpenShift with a free node. I can run composer update from the SSH sessions without any problem.
The only problem is every time I want to commit files through git I have to go to the console and run composer install again. My question is there is any easy way to workaround this? I tried a BASH script in /project/.openshift/action_hooks/post_deploy but the server is not creating the vendor folder under runtime/repo
I always do it via action hooks:
Inside my project directory I have a script called by /project/.openshift/action_hooks/post_deploy where post_deploy is a bash script.
Here goes what I have been using:
#!/bin/bash
export MY_PHPCOMPOSER=$OPENSHIFT_DATA_DIR/composer.phar
# if composer not exists, download
if [ ! -f $MY_PHPCOMPOSER ]; then
cd $OPENSHIFT_DATA_DIR
echo "Downloading composer..."
php -r "readfile('https://getcomposer.org/installer');" | php
fi
$MY_PHPCOMPOSER -n -q self-update
cd $OPENSHIFT_REPO_DIR
# install
php -dmemory_limit=1G $MY_PHPCOMPOSER install
So post_deploy script will perform every time which you push your repo to openshit. It work like a charm!
Side note
Since not always the OpenShift composer's version is updated it's safe
to download a new composer copy and use it.
Also, don't forget adjusting permissions settings.
Helpful links
Openshift builds
Openshift Default Build Lifecycle
I know that my answer is late but according to the Openshift documentation you can enable composer install after each build by just creating a marker file:
touch .openshift/markers/use_composer

Troubles with Homestead / Laravel installation (Mac)

I was following these instructions to install homestead on my Mac
http://pastebin.com/48PHSNC2
Homestead installed properly, but when it initialized, it didn't create a Homestead.yaml file. I have no idea how to reinitialize homestead or fix this. Reading through the installation guide Laravel gives you, it suggests using $ bash init.sh to create the .yaml file... unfortunately, this apparently doesn't exist for me either.
I used the composer command to install the CLI:
composer global require "laravel/homestead=~2.0"
Any ideas? I'm stumped...
I ran into a similar issue using Homestead 2.X (I dont care for Homestead 3 ATM).
basically do the following:
find the bash_init.sh file by running sudo find / -name init.sh
cd into the directory it's in, mine was in /Users/me/.composer/vendor/laravel/homestead/init.sh
make it executable, by running chmod +x init.sh
run ./init.sh
...
profit!
You can generate manually by clone git clone https://github.com/laravel/homestead.git Homestead. This will generate homestead.yaml file. Open and edit and change the parameters to fit your system configuration. For further reading
https://dev.to/ko31/installing-laravel-homestead-on-macos-5910

Laravel 4 PHP Not Found

I am trying to setup my first laravel project. I am running XAMPP for Linux (LAMPP) and I installed composer in /opt/lampp/bin/php.
I then cd /opt/lampp/htdocs
I then run: /opt/lampp/bin/php composer.phar create-project laravel/laravel new_proj --prefer-dist
Everything seems to be going great for the install then I get
Script php artisan optimize handling the post-install-cmd event returned with an error
[Runtime Exception]
Error Output: sh: 1: php: not found
I have PHP 5.4.
I think I understand the error but I don't know Laravel well enough to solve this. I have searched for this and can't seem to find an answer.
Also I can't seem to find a good starting point for trying to install this on XAMPP for Linux (LAMPP). Any help here would be greatly appreciated.
Problem was that I did not specify
/opt/lampp/bin
in my Path so it could not find PHP and more specifically it could not find the version of PHP that I was using in LAMPP. So I added
Path=$PATH:/opt/lampp/bin
to my ~/.bashrc file then I was able to successfully install laravel. Next issue that came up after that was setting permissions on the appropriate folders.
Permissions Problem, See Below:
Set permission for your project folder: sudo chmod 755 -R laravel_proj_name
Set permission for your project storage folder:
sudo chmod o+w -R laravel_proj_name/app/storage
Refresh Page, Good to Go!
I think the problem is that the PHP CLI binary is not in your path. Try adding it to your path or putting a symbolic link into /usr/bin or some other appropriate place.

Categories