Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
matula opened this issue Feb 1, 2017 · 22 comments

Comments

@matula
Copy link

matula commented Feb 1, 2017

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)
@JeffreyWay
Copy link
Collaborator

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

@ghost
Copy link

ghost commented Feb 6, 2017

@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

@matula
Copy link
Author

matula commented Feb 6, 2017

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

@orrd
Copy link

orrd commented Mar 8, 2017

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.

@eddrems
Copy link

eddrems commented Mar 10, 2017

Thanks a lot.. Save my day

@arianacosta
Copy link

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

@jhourlad
Copy link

jhourlad commented Aug 9, 2017

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

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

@ruchernchong
Copy link
Contributor

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

@lightgh
Copy link

lightgh commented Aug 17, 2017

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

@pr4xx
Copy link

pr4xx commented Sep 2, 2017

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

@gitpancake
Copy link

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

@milonfci
Copy link

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

@leegod
Copy link

leegod commented Apr 17, 2018

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.

@ruchernchong
Copy link
Contributor

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

@Bromania
Copy link

Bromania commented Apr 30, 2018

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/<my_user>/.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 <my_user>:
/.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

@SilviaMukherjee
Copy link

@matula
Installing latest version of NVM worked. Thanks. 👍

@JeffLoo-ong
Copy link

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

@maitandat1507
Copy link

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

@LiuZiHua-Andrew
Copy link

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

@mingji
Copy link

mingji commented Nov 8, 2018

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

@hieonn
Copy link

hieonn commented Nov 14, 2018

@mingji Yours works! Thanks!

@mslobodyanyuk
Copy link

mslobodyanyuk commented Jul 6, 2020

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 👍 )

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

No branches or pull requests