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

Created on 7 Jan 2017  路  8Comments  路  Source: JeffreyWay/laravel-mix

I followed the instruction and this is what I get using
os: ubuntu 16.04 desktop.

0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/nodejs', '/usr/bin/npm', 'run', 'dev' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'predev', 'dev', 'postdev' ]
5 info lifecycle [email protected]~predev: [email protected]
6 silly lifecycle [email protected]~predev: no script for predev, continuing
7 info lifecycle [email protected]~dev: [email protected]
8 verbose lifecycle [email protected]~dev: unsafe-perm in lifecycle true
9 verbose lifecycle [email protected]~dev: PATH: /usr/share/npm/bin/node-gyp-bin:/opt/lampp/htdocs/ecampus/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
10 verbose lifecycle [email protected]~dev: CWD: /opt/lampp/htdocs/ecampus
11 silly lifecycle [email protected]~dev: Args: [ '-c',
11 silly lifecycle   'cross-env NODE_ENV=development webpack --watch --progress --hide-modules' ]
12 silly lifecycle [email protected]~dev: Returned: code: 1  signal: null
13 info lifecycle [email protected]~dev: Failed to exec dev script
14 verbose stack Error: [email protected] dev: `cross-env NODE_ENV=development webpack --watch --progress --hide-modules`
14 verbose stack Exit status 1
14 verbose stack     at EventEmitter.<anonymous> (/usr/share/npm/lib/utils/lifecycle.js:232:16)
14 verbose stack     at emitTwo (events.js:87:13)
14 verbose stack     at EventEmitter.emit (events.js:172:7)
14 verbose stack     at ChildProcess.<anonymous> (/usr/share/npm/lib/utils/spawn.js:24:14)
14 verbose stack     at emitTwo (events.js:87:13)
14 verbose stack     at ChildProcess.emit (events.js:172:7)
14 verbose stack     at maybeClose (internal/child_process.js:821:16)
14 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
15 verbose pkgid [email protected]
16 verbose cwd /opt/lampp/htdocs/ecampus
17 error Linux 4.4.0-57-generic
18 error argv "/usr/bin/nodejs" "/usr/bin/npm" "run" "dev"
19 error node v4.2.6
20 error npm  v3.5.2
21 error code ELIFECYCLE
22 error [email protected] dev: `cross-env NODE_ENV=development webpack --watch --progress --hide-modules`
22 error Exit status 1
23 error Failed at the [email protected] dev script 'cross-env NODE_ENV=development webpack --watch --progress --hide-modules'.
23 error Make sure you have the latest version of node.js and npm installed.
23 error If you do, this is most likely a problem with the ecampus package,
23 error not with npm itself.
23 error Tell the author that this fails on your system:
23 error     cross-env NODE_ENV=development webpack --watch --progress --hide-modules
23 error You can get information on how to open an issue for this project with:
23 error     npm bugs ecampus
23 error Or if that isn't available, you can get their info via:
23 error     npm owner ls ecampus
23 error There is likely additional logging output above.
24 verbose exit [ 1, true ]

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 8 comments

You need to update nodeJS

@JeffreyWay in package.json, you can alert users who don't meet minimum nodeJS requirement with...

  "engines": {
    "node": ">= 6.0.0",
  }

(I'm not sure which version is required to run your package; I'm just guessing with 6.0)

You can set engineStrict: true if you want it to actually enforce it instead of just displaying a notice.

@QWp6t and here I thought the latest version of node is 4.+ thank you!

The actual latest version of Node is 7.4, but the minimum version is primarily garnered with Webpack 2 which is 5.x (strongly recommend moving to latest if you are just getting started).

In my case, I had to add "use strict"; to the top of js file in order to get it to work.

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.

Hi friends,
I had found this error while update the npm version...
In my system...

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

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

I go through this link :+1:
https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-ubuntu-16-04
But wat to dooo...

Thanks in advance:)

@Sabrinsulthana do you resolve the problem锛燂紵

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pixieaka picture pixieaka  路  3Comments

RomainGoncalves picture RomainGoncalves  路  3Comments

jpriceonline picture jpriceonline  路  3Comments

rlewkowicz picture rlewkowicz  路  3Comments

amin101 picture amin101  路  3Comments