4

Trying to install LESS/SASS. And getting this error after installing node.js in Linux 16.04. Installed LESS compiler and updatet npm for proceed installing SASS where I failed and now am stuck.

Followed these steps:

  1. sudo apt-get install node.js
  2. sudo apt-get update
  3. sudo apt-get upgrade
  4. sudo apt-get install
  5. npm - node packet manager
  6. sudo npm install -g less
  7. sudo npm install node-sass -g (dind't work)
  8. tried: sudo gem install sass

Then I this error showed up:

$Sudo npm update npm -g 
/usr/local/lib/node_modules/npm/bin/npm-cli.js:82
      let notifier = require('update-notifier')({pkg})
      ^^^

Errormessage

SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:374:25)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Function.Module.runMain (module.js:442:10)
at startup (node.js:136:18)
at node.js:966:3

Since then I can basically do nothing anymore. Not even run a simple command like npm -v. I'll get the same issue over and over again.

Could you please help me?

user3550117
  • 71
  • 1
  • 2
  • 6

3 Answers3

3

It is a reported bug on npm, which versions above 6.0.0 do not support Node versions under Node 6.0.0. If you run node -v there is a strong suspicion that your Node version is older than Node 6.0.0

I ran in the same difficulties by innocently upgrading npm from version 2.14.20 to the latest stable version, with NodeJS on v4.4.0. Problem is that you cannot just upgrade Node since as you mentionned, npm is totally blocked.

So I removed Node using the method described in this question :

I located the directory in which Node components were stored:

which node #this returned /path/bin/node 

Then run cd /path

And eventually run

rm -r bin/node bin/node-waf include/node lib/node lib/pkgconfig/nodejs.pc share/man/man1/node.1

after that, node -v and npm -v would not return anything.

So I dowloaded the node package for Linux : node-v8.11.3-linux-x64.tar.gz, stored it in /tmp and unpacked it:

tar --strip-components 1 -xzf /tmp/node-v8.11.3-linux-x64.tar.gz

Run npm -v and node -v again to check the version. They should be both upgraded.

Hope this helps. :)

The Once-ler
  • 220
  • 3
  • 16
  • Not sure if changing the order would not ruin the clarity of the answer... Anyway, be sure to download the new version **before** removing the previous Node installation (just in case you run in trouble getting the new version, depending on your application constraints it might be troublesome to let Node uninstalled for such a long time) – The Once-ler Jul 27 '18 at 14:37
0

It looks like kicking the whole package and reinstalling it, followed by "autoremove" previous packages solved the issue. Thanks so much guys!

user3550117
  • 71
  • 1
  • 2
  • 6
-1

Since let and const is ECMAScript2015 syntax, you can try upgrading your node.js to a newer (or latest) version that supports es6 syntax. The error message said 'not yet supported outside strict mode'.

TCsss
  • 1
  • 1
  • 1