Css and assests not loading properly

i tried installation of erpnext v14 in local host using native installation (non-docker) method
it works fine in development mode

$ bench start

after CTRL+C
i tried to run it in production mode
i.e bench start in backend
it works in browser but the css and assets are not loading properly


try to fix it by

$ bench build 
$ bench build --production
$ bench --site mysite.erp clear-website-cache

but nothing works to fix the issue , any tip to resolve the issue

Hi,

What installation method was used? What commands were used to setup production?

Hi:

Seems due to permissions on your bench folder.
Check your /var/log/nginx/error.log Anything related?

Hope this helps.

$ sudo apt update -y
$ sudo adduser frappe
$ sudo usermod -aG sudo frappe
$ su frappe
$ cd /home/frappe/
$ sudo apt-get install git python3-dev python3.10-dev python3-setuptools python3-pip python3-distutils python3.10-venv software-properties-common mariadb-server mariadb-client redis-server xvfb libfontconfig wkhtmltopdf libmysqlclient-dev curl nginx supervisor fail2ban -y
$ sudo systemctl start nginx && sudo systemctl enable nginx
$ sudo systemctl start supervisor && sudo systemctl enable supervisor
$ sudo systemctl start fail2ban && sudo systemctl enable nginx
$ sudo systemctl status nginx
$ sudo systemctl status supervisor
$ sudo systemctl status fail2ban

$ sudo mysql_secure_installation

$ sudo vim /etc/mysql/my.cnf
[mysqld]
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
[mysql]
default-character-set = utf8mb4
:wq!

$ sudo service mysql restart
$ sudo systemctl restart mariadb.service
$ sudo systemctl enable mariadb.service

$ sudo curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
$ source ~/.profile
$ nvm install 16.15.0
$ sudo apt-get install npm
$ sudo npm install -g yarn
$ sudo npm install -g yarn
$ node --version
$ sudo pip3 install frappe-bench
$ bench --version
$ bench init frappe-bench
$ cd frappe-bench/
$ chmod -R o+rx /home/frappe
$ bench new-site zha.erp
MySQL root password: ********
Set Administrator password: ********
Re-enter Administrator password: ********
$ bench --site zha.erp add-to-hosts

$ bench --site zha.erp enable-scheduler
$ bench --site zha.erp set-maintenance-mode off

$ sudo bench setup production frappe --yes
$ sudo systemctl reload nginx
$ bench setup nginx
$ sudo supervisorctl restart all
$ sudo bench setup production frappe
$ sudo systemctl reload nginx

http://zha.erp:8000

i give the permissions as

$ chmod -R o+rx /home/frappe

and the logs are

$ sudo tail -f error.log 
2023/05/08 19:18:27 [notice] 5533#5533: using inherited sockets from "6;7;"
2023/05/08 20:18:59 [notice] 5416#5416: signal process started
2023/05/08 20:19:12 [notice] 5423#5423: signal process started
2023/05/08 20:20:03 [notice] 5456#5456: signal process started
2023/05/08 20:20:18 [notice] 5509#5509: signal process started
2023/05/08 20:21:46 [notice] 6372#6372: signal process started
2023/05/08 20:24:54 [notice] 7330#7330: signal process started
1 Like

Has bench build completed without error after setup production?

bench build --production

runs fine without any error

For v14

Add this in your hooks.py app_include_css = "your_app.bundle.css"

Then create a file in your app module public/scss/your_app.bundle.scss

In your_app.bundle.scss file write @import './app.scss';

In this public/scss directory(where your_app.buldle.scss file located) create your custom scss file.

then run bench build --your_app

Hopefully that will work :+1: :+1:

1 Like

I got it working after doing a reinstall. I am using docker to run frappe. But it does the same thing not loading the css and assets maybe after updating the docker image.

If you are getting this:
Run

bench setup requirements
bench build
bench clear-cache
bench clear-website-cache

1 Like