Laravel-mix: SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode

Created on 1 Feb 2017  Â·  22Comments  Â·  Source: JeffreyWay/laravel-mix

Got this while trying to do a fresh install of Spark. Not sure if it's a Spark or Mix issue.
Thanks for any help!

node v4.7.3
npm 4.1.2
spark-installer 1.2.0
OSX 10.11.6

Would you like to compile your assets? (yes/no) [yes]:
 > yes

Running Build Script...

> @ dev /sites
> node node_modules/cross-env/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

/sites/node_modules/laravel-mix/setup/webpack.config.js:120
        let extractPlugin = new plugins.ExtractTextPlugin(
        ^^^

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:373:25)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at requireConfig (/sites/node_modules/webpack/bin/convert-argv.js:96:18)
    at /sites/node_modules/webpack/bin/convert-argv.js:109:17
    at Array.forEach (native)

Most helpful comment

For anyone having this issue with Homestead or similar environments, I was unable to get Node to upgrade using the typical instructions which are usually

sudo npm install -g npm
sudo npm install -g n
sudo n stable

That still wasn't changing the version of Node that was being used. I finally found that you have change the /usr/bin/node symlink like this:

sudo ln -sf /usr/local/n/versions/node/<VERSION>/bin/node /usr/bin/node

Use whatever the highest version is in place of "\" from your install options in /usr/local/n/versions/node.

All 22 comments

Bump your Node dependency. You have 4.7.3, when the current version is 7.4.

@JeffreyWay Could you share the code to update the dependency please? Can't seem to find what I'm looking for

http://stackoverflow.com/questions/42068686/laravel-mix-update-a-node-dependency

Edit: Installed Manually via https://nodejs.org/en/

However this actually downgraded npm from 4.4.5 to 4.1.2..
Node was 2.15.5 now 7.5.0

had to also install a few modules like autoprefixer

@Mapamatician I installed NVM , followed the instructions in the usage section , and everything started working.

For anyone having this issue with Homestead or similar environments, I was unable to get Node to upgrade using the typical instructions which are usually

sudo npm install -g npm
sudo npm install -g n
sudo n stable

That still wasn't changing the version of Node that was being used. I finally found that you have change the /usr/bin/node symlink like this:

sudo ln -sf /usr/local/n/versions/node/<VERSION>/bin/node /usr/bin/node

Use whatever the highest version is in place of "\" from your install options in /usr/local/n/versions/node.

Thanks a lot.. Save my day

Followed @orrd instructions and it worked. For some people, node might be located at /usr/local/bin/node, find out where your node is located by running which node

I wonder why I don't have that n folder even after

sudo npm install -g npm
sudo npm install -g n

@jhourlad Because the folder should be inside node_modules in your global directory of npm that you have configured.

@jhourlad Because you also need to run
sudo n stable
which would actually download and create that folder with the updated version.

I use Bash on Windows (Ubuntu) and still got this error. Node version is 8.4.

@orrd

Thanks! It was the Symbolic Link not working for me, updated the with the version of Node running (9.4.0) and it worked!

@orrd
Thanks!! It's working fine for me.

please post full command line by line. I got a lot error.
sudo:n:command not found,
/usr/bin/env: 'node': No such file or directory.

@leegod looks like you do not even have node installed.

Hi everyone, I have the same issue than @leegod but I had node before. What happened is that i tried to locate node with "which node" :

~$ which node
/home//.nvm/versions/node/v8.9.4/bin/node

Then I used this with @orrd suggestion :

/.nvm/versions/node$ sudo ln -sf /.nvm/versions/node/v8.9.4/bin/node /usr/bin/node
[sudo] password for :
/.nvm/versions/node$

And afterwards when I try to run my work I have now :

/usr/bin/env: ‘node’: No such file or directory

I'm still a newbie so I don't really understand what happened but I think thatÅ› what happened to @leegod

@matula
Installing latest version of NVM worked. Thanks. :+1:

@Bromania This is exactly what I had to do to solve this as well.

This issue happened because of your NodeJS version. My working solution (for Ubuntu):

  1. remove all "node_modules" directory
    sudo rm -rf /usr/local/lib/node_modules/
  2. reinstall
    curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
    sudo apt-get install -y nodejs

@maitandat1507 your way works for me, saving my day!!

Please Update Node

Use n module from npm in order to upgrade node

sudo npm cache clean -f
sudo npm install -g n
sudo n stable
To upgrade to latest version (and not current stable) version, you can use

sudo n latest

@mingji Yours works! Thanks!

For anyone having this issue with Homestead or similar environments, I was unable to get Node to upgrade using the typical instructions which are usually

sudo npm install -g npm
sudo npm install -g n
sudo n stable

That still wasn't changing the version of Node that was being used. I finally found that you have change the /usr/bin/node symlink like this:

sudo ln -sf /usr/local/n/versions/node/<VERSION>/bin/node /usr/bin/node

Use whatever the highest version is in place of " < VERSION > " from your install options in /usr/local/n/versions/node.

@orrd
Thank you SO MUCH, great man :+1: )

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dtheb picture dtheb  Â·  3Comments

sdebacker picture sdebacker  Â·  3Comments

terion-name picture terion-name  Â·  3Comments

Cheddam picture Cheddam  Â·  3Comments

rderimay picture rderimay  Â·  3Comments