10

I'm building a desktop app using electron and vue, things went normal running the app in dev mode and building it untill the last building by running electron:build but I keep getting this error of Octal escape sequences.

I am pretty sure that it has to deal with the strict mode, but I tried to find the ocatal escapes but no chance, I tried to remove some useless dependencies the I added after the last successful build also didn't work


PS: the electron:serve works fine

err picture

enter image description here

background.js from Terser Octal escape sequences are not allowed in template strings [background.js:1026,68555]

ERROR Build failed with errors. npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! keyboard-managment@0.1.0 electron:build: vue-cli-service electron:build npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the keyboard-managment@0.1.0 electron:build script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

Rahul Singh
  • 918
  • 14
  • 31
Hakim Baheddi
  • 237
  • 1
  • 2
  • 10

6 Answers6

10

The issue is in background.js. In lines 1026 and 68555, look for a template string with an octal sequence in it. Example:

console.log(`Octal sequences like \033 are not allowed here`)

You can revert the es6 template to a (regular) string instead:

console.log("Octal sequences like \033 are allowed here")

Or you might try a different, permitted encoding, e.g.,

console.log(`Sequences like \2264 are not allowed here`);
console.log(`But sequences like \u2264 are allowed`);
JohnK
  • 6,865
  • 8
  • 49
  • 75
Matt Simerson
  • 1,001
  • 1
  • 10
  • 22
2

Sorry this is a rather late response, but there is in fact a way to use octal escape sequences in template strings. You add the octal sequence using a normal string inside it. For example:

let myString = `foo ${"\033"} bar`

This is similar to adding the strings together:

let myString = `foo ` + "\003" + ` bar`
SirFireball
  • 91
  • 1
  • 6
0
console.log(String.raw `Octal sequences like \033 are not allowed here`)
belqit
  • 1
0

I landed here when trying to change terminal output while in Typescript and strict mode. None of the above answers really covered it.

The original Javascript template string used the octal escape \033:

`${info.timestamp} [${info.level}] \033[35m${info.label}\033[39m: ${info.message}`

However, these are deprecated when in strict mode. So the solution is to convert into a hexadecimal escape sequence instead: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Deprecated_octal

This means you have to do the octal-to-hexadecimal conversion and turn \033 into \x1B like so:

`${info.timestamp} [${info.level}] \x1B[35m${info.label}\x1B[39m: ${info.message}`

This way the output of info.label in this example is color-coded as expected in a terminal window.

Reno
  • 1
  • 1
-1

If you're on windows, change the backslashes into forward slashes

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Mar 10 '23 at 13:07
-2

As pointed out in the section on ES2016 behavior, octal strings work fine when started by \0o rather than \0:

This does not work:

console.log(`\033]0;Some title\007`);

but this does:

console.log(`\0o33]0;Some title\0o07`);

and has the desired effect of setting the terminal title.

Christian Fritz
  • 20,641
  • 3
  • 42
  • 71