Hello when I run this project in Developer mode (grunt server) https://github.com/kennethlynne/generator-angular-xl everything is ok but when I run it in production mode (grunt build) I get an `
Uncaught SyntaxError: In strict mode code, functions can only be declared at top level or immediately within another function
Anyone have any idea what's going on? Thanks,
Ps. I posted a link to the project instead of code since the JS is split in many files.
Strict mode is declared by adding "use strict"; to the beginning of a script or a function.
Using Strict mode for a function: Likewise, to invoke strict mode for a function, put the exact statement “use strict”; (or 'use strict';) in the function's body before any other statements. Examples of using Strict mode: Example: In normal JavaScript, mistyping a variable name creates a new global variable.
If you are using native JavaScript modules, then all the code within your modules will be in strict mode by default.
It's just what the error message says:
functions can only be declared at top level or immediately within another function
You must not put a function declaration inside any other block, like an if-statement or for-loop.
Example:
'use strict';
function some() {
function okay() {
}
let x = 1;
function no_problem() {
}
if (x == 1) {
function BOOM() { // <- wrong!
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With