SyntaxError: Use of const in strict mode?
Updating nodejs
solved the issue:
npm cache clean -f
sudo npm install -g n
sudo n stable
node --version
node app.js
You have to run the second and third command as root/administrator.
SyntaxError: Use of const in strict mode inside github and codeship
Because those folder structure is not defined as we configure in our server.
This issue has nothing to do with folder structures.
Your project is currently using Node version 0.12.6
which is extremely out of date. The current LTS version of Node is 6.11.3
and the current version is 8.6.0
.
The specific issue is SyntaxError: Use of const in strict mode.
which means the libraries you are using are currently utilizing ES2015 syntax or higher. The root cause of the issue is in the Boom module, which uses const
at line 5 (and most likely other current syntax as well).
The solution for your issue here is to update the node version being utilized inside Codeship.
nvm install 6.11.3
nvm use 6.11.3
Use of const in strict mode error while running nodeJS code
I found the answer to the problem, we need update nodejs stable
sudo npm clean -f
sudo npm install -g n
sudo n stable
These commands will downloaded the new stable version of NodeJS. After updating NodeJS using these codes, there are no problems.
Use of const in strict mode : Azure Web App
Looks like it's caused by an invalid node version on Azure. Go to Azure portal, your Web App - Application settings, check WEBSITE_NODE_DEFAULT_VERSION
.
Once we specify a version not available on Azure, a quite old version 0.10.40 is in use, where const
is not enabled by default so that we met SyntaxError: Use of const in strict mode
. See related thread for more details.
We can use 10.6.0, 8.11.1, etc. Go to https://<yourwebappname>.scm.azurewebsites.net/api/diagnostics/runtime
to see all versions available.
Caveat by Clinkz
In some cases, the above solution may not work. This may be because your project includes the file iisnode.yml
. If this file exists, it overrides application settings environment variable. The content of this file should be as follows :
nodeProcessCommandLine: "%SystemDrive%\Program Files (x86)\nodejs\0.10.4\node.exe"
The node version specified here takes precendence. To fix it, simply update the version, like so and deploy:
nodeProcessCommandLine: "%SystemDrive%\Program Files (x86)\nodejs\8.9.4\node.exe"
Refer to this.
To conclude, the priority: iisnode.yml > package.json(engine)> Application settings. Application setting is recommended as it's easy to check and modify on portal.
Update to Grunt causes Use of const in strict mode error
We encountered this issue as well. Turns out our build agents started using grunt@1.0.3 node_modules/grunt (not sure how or why, it looks like this update to grunt happened 16 days ago, but it just changed on our agents today)
Which appears to rely on:
grunt-legacy-log@2.0.0 (hooker@0.2.3, colors@1.1.2, grunt-legacy-log-utils@2.0.1, lodash@4.17.10)
With grunt-legacy-log-utils@2.0.1 which appears to rely on chalk, which appears to rely on:
escape-string-regexp (https://www.npmjs.com/package/grunt-legacy-log-utils/v/2.0.1)
We resolved the build issue by specifying grunt@1.0.2 which uses:
grunt-legacy-log@1.0.2 (hooker@0.2.3, colors@1.1.2, grunt-legacy-log-utils@1.0.0, lodash@4.17.10)
After setting the build back to using grunt <1.0.3 the build started working. Hope it helps!
Related Topics
How to Apply CSS to Only Numbers in a Text Inside/Or Any <P><P> Element
How to Show Just the First Line of Text of a Div and Expand on Click
Set Height of <Div> = to Height of Another <Div> Through .Css
How to Get a Floating Footer to Stick to the Bottom of the Viewport in Ie 6
Jquery CSS Rendering - Works in Firefox, Not in Chrome
Positioning Multiple, Random Sized, Absolutely Positioned Elements So They Don't Overlap
Set the Webkit-Keyframes From/To Parameter with JavaScript
Blinking/Flickering with Jqm and Phonegap on Android
Restart a Gif Animation Without Reloading the File
Why Does Reflow Need to Be Triggered for CSS Transitions
Get All Computed Style of an Element
Getcomputedstyle (Or) $.Css(Map) <-- to Get Every Style Declaration
Programmatically Editing Less (Css) Code with Jquery-Like Selector Syntax
How to Dynamically Remove a Stylesheet from the Current Page
Converting Em to Px in JavaScript (And Getting Default Font Size)
Cross-Browser Method to Determine Vertical Scroll Percentage in JavaScript