sass / node-sass

:rainbow: Node.js bindings to libsass
https://npmjs.org/package/node-sass
MIT License
8.51k stars 1.32k forks source link

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

Closed Bugget closed 7 years ago

Bugget commented 7 years ago

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 commented 7 years ago

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

https://github.com/request/request/commit/479143d546d6dff378da0e5fac5801dd3bf01f15

Bugget commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

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

mirzazeyrek commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

quick fix: npm install node-sass request@2.81.0

majidpal commented 7 years ago

Thanks for update. I am already having "npm install" used. Should I remove this line and use one suggested by you.

I tried using npm install npm install node-sass request@2.81.0 but still giving error.

On 21-Sep-2017 12:52 am, "Karsten" notifications@github.com wrote:

quick fix: npm install node-sass request@2.81.0

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/sass/node-sass/issues/2100#issuecomment-330954381, or mute the thread https://github.com/notifications/unsubscribe-auth/Aephblcclmp1fpSohNktz5zGsGDGy5s6ks5skWXdgaJpZM4PdDZz .

nschonni commented 7 years ago

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 commented 7 years ago

@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 request@2.81.0 shrinkwrap
npm init # make sure <=2.81.0
npm prune
npm shrinkwrap
majidpal commented 7 years ago

Thanks you for response. We are planning to move away with this version but the for temprary need to fix so that work can continue. I am using below in my jobs -

./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; \ npm install -g bower; \ bower install --allow-root --config.interactive=false ;\ npm run build npm run cache-buster npm run www-build-index"

in my package.json we have gulp-sass": "^2.1.1"

Please let me know what to change. Appreciate help.

On Thu, Sep 21, 2017 at 9:49 AM, Karsten notifications@github.com wrote:

@majidpal https://github.com/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 request@2.81.0 shrinkwrap npm init # make sure <=2.81.0 npm prune npm shrinkwrap

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/sass/node-sass/issues/2100#issuecomment-331046889, or mute the thread https://github.com/notifications/unsubscribe-auth/Aephbuj6n9vpD2-VUPtx1yOxytzDs4nGks5skeO8gaJpZM4PdDZz .

majidpal commented 7 years ago

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 request@2.81.0; \ 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 commented 7 years ago

Looks like this is all caused by https://github.com/hueniverse/hawk/issues/153 from 2 years ago...

saper commented 7 years ago

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

alexweissman commented 7 years ago

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 request@2.81.0 translate into a change in our package.json?

kmcminn commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

update to ^2.8 solved for me

saper commented 7 years ago

Looks like request switched to hawk 3.1.3 in https://github.com/request/request/pull/2789

xzyfer commented 7 years ago

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

Thoughts @saper @nschonni ?

nschonni commented 7 years ago

@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 commented 7 years ago

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 request@2.81.0
majidpal commented 7 years ago

@Michael - I wanted to move to latest node and i did trued node 6.X version but it was still failing with same error "SyntaxError: Use of const in strict mode."

Please let me konw which is the stable latest version available and steps for them , so that I can put this up to development team and migrate to that.

Thanks for support.

On Fri, Oct 6, 2017 at 9:21 AM, Michael Mifsud notifications@github.com wrote:

Closed #2100 https://github.com/sass/node-sass/issues/2100.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/sass/node-sass/issues/2100#event-1281100966, or mute the thread https://github.com/notifications/unsubscribe-auth/AephbjUJpkvcxuxf1YjJfWstJTZRrHNkks5spaPTgaJpZM4PdDZz .

azaharakis commented 7 years ago

@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?

elewinso commented 6 years ago

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 commented 6 years ago

This is resolved in the latest node-sass. Run npm update node-sass

On 5 Feb. 2018 3:19 am, "Eyal Lewinsohn" notifications@github.com wrote:

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",

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/sass/node-sass/issues/2100#issuecomment-362919095, or mute the thread https://github.com/notifications/unsubscribe-auth/AAjZWO5wIC_G7ODntoVLRCMtzdr-0Dntks5tRdiUgaJpZM4PdDZz .