SyntaxError: Unexpected token (80:2) when I install ERPNext

Hi @everyone I’m installing ERPNext on Ubuntu 18.
when I run bench get-app erpnext https://github.com/frappe/erpnext I get the following error

I tried 4 to 5 times but no changes in error
please help someone

this is caused by an error in erpnext/public/js/hub/hub_factory.js

the 2nd line to be changed to
frappe.views.HubFactory = frappe.views.Factory.extends ({

full code as below

frappe.provide('erpnext.hub.pages');

frappe.views.HubFactory =  frappe.views.Factory.extends ({
	make(route) {
		const page_name = frappe.get_route_str();
		const page = route[1];

		const assets = {
			'List': [
				'/assets/erpnext/js/hub/hub_listing.js',
			],
			'Form': [
				'/assets/erpnext/js/hub/hub_form.js'
			]
		};
		frappe.model.with_doc('Hub Settings', 'Hub Settings', () => {
			this.hub_settings = frappe.get_doc('Hub Settings');

			if (!erpnext.hub.pages[page_name]) {
				if(!frappe.is_online()) {
					this.render_offline_card();
					return;
				}
				if (!route[2]) {
					frappe.require(assets['List'], () => {
						if(page === 'Favourites') {
							erpnext.hub.pages[page_name] = new erpnext.hub['Favourites']({
								parent: this.make_page(true, page_name),
								hub_settings: this.hub_settings
							});
						} else {
							erpnext.hub.pages[page_name] = new erpnext.hub[page+'Listing']({
								parent: this.make_page(true, page_name),
								hub_settings: this.hub_settings
							});
						}
					});
				} else if (!route[3]){
					frappe.require(assets['Form'], () => {
						erpnext.hub.pages[page_name] = new erpnext.hub[page+'Page']({
							unique_id: route[2],
							doctype: route[2],
							parent: this.make_page(true, page_name),
							hub_settings: this.hub_settings
						});
					});
				} else {
					frappe.require(assets['List'], () => {
						frappe.route_options = {};
						frappe.route_options["company_name"] = route[2]
						erpnext.hub.pages[page_name] = new erpnext.hub['ItemListing']({
							parent: this.make_page(true, page_name),
							hub_settings: this.hub_settings
						});
					});
				}
				window.hub_page = erpnext.hub.pages[page_name];
			} else {
				frappe.container.change_to(page_name);
				window.hub_page = erpnext.hub.pages[page_name];
			}
		});
	},

	render_offline_card() {
		let html = `<div class='page-card' style='margin: 140px auto;'>
			<div class='page-card-head'>
				<span class='indicator red'>${'Failed to connect'}</span>
			</div>
			<p>${ __("Please check your network connection.") }</p>
			<div><a href='#Hub/Item' class='btn btn-primary btn-sm'>
				${ __("Reload") }</a></div>
		</div>`;

		let page = $('#body_div');
		page.append(html);

		return;
	}
})
1 Like

dear @szufisher thanks for replying
I’m cloning from github. do I need to change the code?

yes, you need to manually change the cloned code

1 Like

IT worked Thanks a lot

Hey do I need to bench update --reset after altering the file in question

A fix for the same has been sent for now.

@kennethsequeira do I need to stash my local changes and pull, the error is solved in github?

No you don’t
It worked for me without reset.
but if you update syntax error should solved in github.

1 Like