Upgrade v10->v11: Syntax error

Hello, all.
I finally run upgrade to v11.
After “bench update” I received many remarks about installinig yarn and finally:
Failed at the frappe@ production script ‘FRAPPE_ENV=production node rollup/build.js’.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the frappe package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! FRAPPE_ENV=production node rollup/build.js

then, I installed yarn: sudo npm install -g yarn
and run update again with --reset. It failed with:

Updating node packages…
INFO:bench.utils:yarn install
let {
SyntaxError: Unexpected token {
at NativeCompileCache._moduleCompile (/usr/lib/node_modules/yarn/lib/v8-compile-cache.js:226:18)
at Module._compile (/usr/lib/node_modules/yarn/lib/v8-compile-cache.js:172:36)
at Object.Module._extensions…js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
at require (internal/module.js:20:19)
at Object. (/usr/lib/node_modules/yarn/bin/yarn.js:24:13)
at Module._compile (module.js:413:34)
at Object.Module._extensions…js (module.js:422:10)
Traceback (most recent call last):
File “/usr/local/bin/bench”, line 11, in
load_entry_point(‘bench’, ‘console_scripts’, ‘bench’)()
File “/home/frappe/bench-repo/bench/cli.py”, line 40, in cli
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 722, in call
return self.main(*args, **kwargs)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 697, in main
rv = self.invoke(ctx)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 535, in invoke
return callback(*args, **kwargs)
File “/home/frappe/bench-repo/bench/commands/update.py”, line 60, in update
_update(pull, patch, build, bench, auto, restart_supervisor, restart_systemd, requirements, no_backup, force=force, reset=reset)
File “/home/frappe/bench-repo/bench/commands/update.py”, line 77, in _update
File “/home/frappe/bench-repo/bench/utils.py”, line 449, in update_node_packages
File “/home/frappe/bench-repo/bench/utils.py”, line 462, in update_yarn_packages
exec_cmd(‘yarn install’, cwd=app_path)
File “/home/frappe/bench-repo/bench/utils.py”, line 159, in exec_cmd
raise CommandFailedError(cmd)
bench.utils.CommandFailedError: yarn install

I run as recommended:
sudo npm install express
sudo npm install socket.io
and then again the bench update --reset, but received the same error.

Now, my ErpNext works only for reading. I can’t save new PO - save button does nothing.

What can be done more?
Urgent help will be highly appreciated.

“Now, my ErpNext works only for reading. I can’t save new PO - save button does nothing.”

Please start a new thread with a screenshot.

Sorry, please, why should I start a new topic? Isn’t my problem the result of improper update?

Your subject refers to a syntax error that you have resolved yes?

Might also be useful to have your distro and version

Are you running all these commands as user frappe and from frappe-bench? Running as a different user or root could cause odd errors.

I hadn’t solved none of the problems.

Attempt to run simple “nmp install -g yarn” failed with “permission” error. So I tried to run “sudo nmp…”. This installed yarn, but “bench update” failed with syntax error I citated.

Without the yarn installation the update error " script ‘FRAPPE_ENV=production node rollup/build.js" is the result. And attempt to run in this state ends with “no save” state.

My distro is ERPMNext VM updated till the last v10 update (IMHO 10.6, as I remember).

ok you tried two alternatives but neither worked.

A search on ‘npm install -g yarn’ and ‘sudo npm install -g yarn’ should help resolve your permission problem.

This search may give clues ‘npm ERR! FRAPPE_ENV=production node rollup/build.js’

To run ‘bench update’ with a running instance (ie run ‘bench start’ in another console) is worth a try.

Nothing helps - I can’t move beyond this Syntax Error.
I tried your recommendations - didn’t find something helping too.
Also running bench doesn’t influence…
Is there any way to install 11 above 10.6 and not ruin my existing data?
Sorry for stupid question - I am newbie in this area of programming…

Juilan asks this since to run as root, or to run bench commands as sudo, invites permission problems (for eg: ‘sudo bench update’ calls in turn git pull that changes file ownership to root, I think)

Yes run a fresh install of V11, then restore your data from v10 to that. Be sure the install user (for eg frappe) has sudo privileges.

hope this helps

Sorry - as I said, I am newbie in this.
How can I restore my data from v10? Just a link to read about…:slight_smile:

For eg revant has authored much on that topic https://discuss.erpnext.com/search?q=%40revant_one%20backup%20restore

ok yes to confirm - when you create a file with sudo, file ownership is root.

Here’s a demo test of this:

frappe@ubuntu:~$ touch dummy.txt
frappe@ubuntu:~$ sudo touch sudodummy.txt

frappe@ubuntu:~$ ls -al *dummy.txt
-rw-rw-r-- 1 frappe frappe 0 Feb 21 17:36 dummy.txt
-rw-r--r-- 1 root   root   0 Feb 21 17:36 sudodummy.txt

frappe@ubuntu:~$ touch sudodummy.txt 
touch: cannot touch 'sudodummy.txt': Permission denied

John, I am a newbie in ERPNext, but not in Linux.

Under root I only run the npm install yarn, IMHO this doesn’t mean that files are created with root permissions.

All bench operations I did under user “frappe”.

And the result always arrived to the syntax error.

Actually, I looked into the file and there is a strange text there, which doesn’t look like JSON code, but who am I to decide…

Total frustration.
I installed fresh installation of v11. But when I run “bench update” of the freshly installed v11 I received the same exactly error!!!:
Syntax error: unexpected token {
and exactly at the same place cli.js:45726.
Please, help!!!

Things to try:

‘bench build’

Run json lint on node_modules Strange issue with JSON file when update ERPNext

OK, the solution is found, although it is so strange…
After I run:
sudo apt-get update
sudo apt-get upgrade
sudo reboot
cd frappe-bench
bench update

I finally received working v11 with my DB.