Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

Use of const in strict mode causing failures installing Node 0.12 #2100

Closed
Bugget opened this issue Sep 19, 2017 · 29 comments
Closed

Use of const in strict mode causing failures installing Node 0.12 #2100

Bugget opened this issue Sep 19, 2017 · 29 comments

Comments

@Bugget
Copy link

Bugget commented Sep 19, 2017

  • NPM version: 2.11.3
  • Node version: 0.12.7
  • Node Process: { http_parser: '2.3',
    node: '0.12.7',
    v8: '3.28.71.19',
    uv: '1.6.1',
    zlib: '1.2.8',
    modules: '14',
    openssl: '1.0.1p' }
  • Node Platform: linux
  • Node architecture: x64
    ./ui/node_modules/gulp-sass/node_modules/node-sass/node_modules/request/node_modules/hawk/node_modules/boom/lib/index.js:5
    const Hoek = require('hoek');
    ^^^^^
    SyntaxError: Use of const in strict mode.
    at exports.runInThisContext (vm.js:73:16)
    at Module._compile (module.js:443:25)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object. (/home/tbugge/mocat/ui/node_modules/gulp-sass/node_modules/node-sass/node_modules/request/node_modules/hawk/lib/index.js:5:33)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)

Looks like a dependency changed. I took a quick look at the releases on hawk and boom and didn't see anything recent. This stopped building with this error in the last hour or so.

@kshay
Copy link

kshay commented Sep 19, 2017

We just hit this too. It looks like it was caused by this update to request:

request/request@479143d

@Bugget
Copy link
Author

Bugget commented Sep 19, 2017

Indeed that was it. In our package.json file we just added a hard set of request to version 2.81.0 which is before they set hawk to 6.x and that fixed the build. So long as all your tests pass that is a work around.

@mirzazeyrek
Copy link

This error message started to appear recently. Is there anything you guys suggest may be ?

/node_modules/grunt-sass/node_modules/node-sass/node_modules/request/node_modules/hawk/node_modules/boom/lib/index.js:5
11:16:32 const Hoek = require('hoek');
11:16:32 ^^^^^
11:16:32 SyntaxError: Use of const in strict mode.
11:16:32 at exports.runInThisContext (vm.js:73:16)
11:16:32 at Module._compile (module.js:443:25)
11:16:32 at Object.Module._extensions..js (module.js:478:10)
11:16:32 at Module.load (module.js:355:32)
11:16:32 at Function.Module._load (module.js:310:12)
11:16:32 at Module.require (module.js:365:17)
11:16:32 at require (module.js:384:17)
11:16:32 at Object. (/var/jenkins/workspace/artbees-portal/pr/253/node_modules/grunt-sass/node_modules/node-sass/node_modules/request/node_modules/hawk/lib/index.js:5:33)
11:16:32 at Module._compile (module.js:460:26)
11:16:32 at Object.Module._extensions..js (module.js:478:10)

@elmer
Copy link

elmer commented Sep 20, 2017

got bitten by this too. had to lock request to 2.81.0

@mirzazeyrek
Copy link

mirzazeyrek commented Sep 20, 2017

Looks like preventing this is possible.

If you have a working version prior to update go to that installation and use:

npm shrinkwrap 
or
npm shrinkwrap --dev

then a new file will be created

npm-shrinkwrap.json

Check that file and make sure dependencies are created. Normally this file has all the existing dependencies. Put that file in the folder which you run npm install inside. NPM will use the old versions and should work.

As an alternative you can remove all unrelated dependencies and keep only node-sass with request dependency.

          "node-sass": {
            "version": "2.1.1",
            "from": "node-sass@>=2.0.1 <3.0.0",
            "resolved": "https://registry.npmjs.org/node-sass/-/node-sass-2.1.1.tgz",
            "dependencies": {
              "request": {
                "version": "2.79.0",
                "from": "request@>=2.53.0 <3.0.0",
                "resolved": "https://registry.npmjs.org/request/-/request-2.79.0.tgz",
              },
            }
          },

@majidpal
Copy link

Hi @Bugget - We are facing same issues and we are using node:0.12.7 version of image. Please can you help what changes are required to resolve this issue.

@kmcminn
Copy link

kmcminn commented Sep 20, 2017

quick fix: npm install node-sass [email protected]

@nschonni nschonni changed the title Use of const in strict mode Use of const in strict mode causing failures installing Node 0.12 Sep 20, 2017
@majidpal
Copy link

majidpal commented Sep 21, 2017 via email

@nschonni
Copy link
Contributor

I'm going to leave this unlocked, and not speaking for any of the other maintainers, but 0.12 has been EOL since January 1st. I don't know how much effort will be put into fixing this, but I do appreciate the folks suggesting the workaround by pinning the request dependency.

@kmcminn
Copy link

kmcminn commented Sep 21, 2017

@majidpal to fix versions you'll need prune, shrinkwrap and a correct package.json. In a fresh repo that would look like:

npm install node-sass [email protected] shrinkwrap
npm init # make sure <=2.81.0
npm prune
npm shrinkwrap

@majidpal
Copy link

majidpal commented Sep 21, 2017 via email

@majidpal
Copy link

We were able to resolve issue by adding bolded line. This needs to comer before npm install -

./docker run --rm -t
-v "/data/jenkins/home/jobs/test/workspace/:/src/"
node:0.12.7 bash -c "git config --global url."https://".insteadOf git://;
cd /src;
npm install gulp-sass [email protected];
npm install;
npm install -g bower;
bower install --allow-root --config.interactive=false ;
npm run build
npm run cache-buster
npm run www-build-index"

Still have an open question - We had tried using latest version of image node:6.3.5 but still it was failing. I hope latest node image should have point to current version of gulp-sass.

Can you please let me know which latest stable version we should use so that explicit download of gulp-sass is not required?

@saper
Copy link
Member

saper commented Sep 21, 2017

Looks like this is all caused by mozilla/hawk#153 from 2 years ago...

@saper
Copy link
Member

saper commented Sep 21, 2017

@nschonni @xzyfer what about making a snapshot release locked to [email protected] and being the last one to support 0.10, 0.12 (and provide binaries for them)?

@alexweissman
Copy link

We're experiencing this issue with our Travis CI job for the Select2 repo: https://travis-ci.org/select2/select2/jobs/279037851. How does npm install node-sass [email protected] translate into a change in our package.json?

@kmcminn
Copy link

kmcminn commented Sep 24, 2017

package.json generated from my previous comment:

{
<SNIP>
  "dependencies": {
    "node-sass": "^4.5.3",
    "request": "<=2.81.0",
    "shrinkwrap": "^0.4.0"
  },
<SNIP>
}

Switch to using package.json and npm-shrinkwrap.json to manage transitive dependencies deterministically.

https://github.com/uber/npm-shrinkwrap
https://docs.npmjs.com/files/package.json

@alexweissman
Copy link

Thanks! I'm pretty green with respect to npm and Node in general (I'm primarily a PHP developer), but I'll bring this up with the project creators!

@garlou
Copy link

garlou commented Sep 25, 2017

Updating npm and nodejs worked for me:

curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
npm install -g npm@latest```

@tekstrand
Copy link

We've run into this as well across a few of our environments. Success locally with the temporary fix provided by @kmcminn and are trying to update our deployment scripts now accordingly.

@Laxmantln
Copy link

Below error/issue resolved with this solution:

Solution:

sed -i '27 a "request":"2.81.0",' /opt/apache-ambari-2.2.2-src/ambari-web/package.json

I just added specified "request" version(older version "2.81.0") in "package.json" file below problem resolved.

Here is my error:

[INFO]
[INFO] --- exec-maven-plugin:1.2.1:exec (compile-brunch) @ ambari-web ---
[DEBUG] Configuring mojo org.codehaus.mojo:exec-maven-plugin:1.2.1:exec from plugin realm ClassRealm[plugin>org.codehaus.mojo:exec-maven-plugin:1.2.1, parent: sun.misc.Launcher$AppClassLoader@5c647e05]
[DEBUG] Configuring mojo 'org.codehaus.mojo:exec-maven-plugin:1.2.1:exec' with basic configurator -->
[DEBUG] (f) basedir = /opt/apache-ambari-2.2.2-src/ambari-web
[DEBUG] (f) classpathScope = runtime
[DEBUG] (f) commandlineArgs = build
[DEBUG] (f) executable = brunch
[DEBUG] (f) longClasspath = false
[DEBUG] (f) project = MavenProject: org.apache.ambari:ambari-web:2.2.2.0.0 @ /opt/apache-ambari-2.2.2-src/ambari-web/pom.xml
[DEBUG] (f) session = org.apache.maven.execution.MavenSession@5ce4369b
[DEBUG] (f) skip = false
[DEBUG] (f) workingDirectory = /opt/apache-ambari-2.2.2-src/ambari-web
[DEBUG] -- end configuration --
[DEBUG] Executing command line: brunch build

/opt/apache-ambari-2.2.2-src/ambari-web/node_modules/ember-precompiler-brunch/node_modules/jsdom/node_modules/request/node_modules/hawk/node_modules/boom/lib/index.js:5
const Hoek = require('hoek');
^^^^^
Error: You probably need to execute npm install to install brunch plugins. SyntaxError: Use of const in strict mode.
at /opt/node-v0.10.44-linux-x64/lib/node_modules/brunch/lib/watch.js:433:19
at Array.map (native)
at loadDeps (/opt/node-v0.10.44-linux-x64/lib/node_modules/brunch/lib/watch.js:418:10)
at loadPackages (/opt/node-v0.10.44-linux-x64/lib/node_modules/brunch/lib/watch.js:438:15)
at /opt/node-v0.10.44-linux-x64/lib/node_modules/brunch/lib/watch.js:458:19
at /opt/node-v0.10.44-linux-x64/lib/node_modules/brunch/lib/helpers.js:529:16
at /opt/node-v0.10.44-linux-x64/lib/node_modules/brunch/lib/helpers.js:485:14
at /opt/node-v0.10.44-linux-x64/lib/node_modules/brunch/node_modules/read-components/index.js:263:16
at /opt/node-v0.10.44-linux-x64/lib/node_modules/brunch/node_modules/read-components/index.js:72:14
at Object.cb [as oncomplete] (fs.js:169:19)

[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Ambari Main ........................................ SUCCESS [ 3.970 s]
[INFO] Apache Ambari Project POM .......................... SUCCESS [ 0.591 s]
[INFO] Ambari Web ......................................... FAILURE [01:08 min]

@lucksp
Copy link

lucksp commented Sep 30, 2017

update to ^2.8 solved for me

@saper
Copy link
Member

saper commented Sep 30, 2017

Looks like request switched to hawk 3.1.3 in request/request#2789

@xzyfer
Copy link
Contributor

xzyfer commented Oct 6, 2017

We're already locked to a handful of outdate packages that have dropped Node 0.10 support. I'm not sure how long we can continue to do this dance though when any transitive dependency can hurt us like this.

We'll be officially dropping support for Node < 6 in node-sass@v5 later this year. In the mean time I suggest we

  • continue to support old Node versions in the form of supplying prebuilt binaries
  • create a locked issue documenting how to install a working version of request for Node < 4

Thoughts @saper @nschonni ?

@nschonni
Copy link
Contributor

nschonni commented Oct 6, 2017

@xzyfer I think adding it to the TROUBLESHOOTING or README might be helpful. When we break in 5, we can make an explicit message too

@xzyfer
Copy link
Contributor

xzyfer commented Oct 6, 2017

Node Sass 4.x continues to support Node < 4.

However due to some of our dependencies dropping support older Node versions npm install will fail an error like

SyntaxError: Use of const in strict mode.

This is out of our control. We recommend updating Node to an active LTS or current version 6, 7, or 8 if possible. The next major version of Node Sass will remove support for Node < 6.

If you must support Node < 4 you can explicitly install an older version of request for node-sass to use by running the following

npm install --save [email protected]

@xzyfer xzyfer closed this as completed Oct 6, 2017
xzyfer added a commit that referenced this issue Oct 6, 2017
These will always fails now due to #2100. We manually verify support when building release binaries so there's no value in failing CI. It's scary to contributors.
xzyfer added a commit that referenced this issue Oct 6, 2017
These will always fails now due to #2100. We manually verify support when building release binaries so there's no value in failing CI. It's scary to contributors.
xzyfer added a commit that referenced this issue Oct 6, 2017
* Remove Node 0.10 and 0.12 from travis config

These will always fails now due to #2100. We manually verify support when building release binaries so there's no value in failing CI. It's scary to contributors.

* Remove Node 0.10 and 0.12 from appveyor config

These will always fails now due to #2100. We manually verify support when building release binaries so there's no value in failing CI. It's scary to contributors.

* Link to the troubleshoot guide for Node < 4 installation issues

Help people search for keywords because noone reads the help guides anyway.
@majidpal
Copy link

majidpal commented Oct 6, 2017 via email

@azaharakis
Copy link

@xzyfer, thanks for the solution! Curious how this works as it goes against my understanding of how NPM v2 structures its dependencies (which would be the version tied to > node 4)
https://docs.npmjs.com/how-npm-works/npm2
Since node-sass specifies it's version of request my understanding was that it would use this version in it's dependency tree, and ignore the version specified by the user's dependencies?

donnapep added a commit to Automattic/sensei that referenced this issue Nov 28, 2017
The versions of node and npm are old and may be the cause of the CCI
build failure as per sass/node-sass#2100.
sonata82 added a commit to sonata82/daily-comic.js that referenced this issue Dec 13, 2017
k-okada added a commit to tork-a/live-cd2 that referenced this issue Jan 4, 2018
@elewinso
Copy link

elewinso commented Feb 4, 2018

I had this happen using manifoldJS for packaging an edge extension.
to fix it I had to update
C:\Users\eyal\AppData\Roaming\npm\node_modules\manifoldjs\node_modules\manifoldjs-lib\package.json
changing the request dependency to
"request": "<=2.81.0",

@xzyfer
Copy link
Contributor

xzyfer commented Feb 4, 2018 via email

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests