SyntaxError: Unexpected token => - laravel

When I ran the gulp command from the root of the project, a problem turned out.
elixir((mix) => {
SyntaxError: Unexpected token =>
at exports.runInThisContext (vm.js:73:16)
at Module._compile (module.js:443:25)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at execute (D:\nodejs\node_global\node_modules\gulp-cli\lib\versioned\^3.7.0\index.js:24:18)
at Liftoff.handleArguments (D:\nodejs\node_global\node_modules\gulp-cli\index.js:149:63)
at Liftoff.<anonymous> (D:\nodejs\node_global\node_modules\gulp-cli\node_modules\liftoff\index.js:198:16)
The gulpfile is from a Laravel Project, here it is https://github.com/rappasoft/laravel-5-boilerplate/blob/master/gulpfile.js .
I had searched the problem above over stack and other network station, but couldn't find any useful advise.
Btw, it was run on Windows, you can get it from the details code above.
If somebody can help, I will be very appreciate . THX !

Arrow function are new JavaScript (ES6), so maybe your node and npm version is old and you should upgrade it. Use this official installer.
https://nodejs.org/dist/v6.9.2/node-v6.9.2-x64.msi

Related

How to fix Unexpected token { when running npx cypress?

I run
npx cypress
And get
Unexpected token {
Maybe there is a way to get more details, tried:
DEBUG=cypress:server:socket-base npx cypress
But still same error and no more info. First it was working, I think I did not change anything and one day it started giving this error. Maybe I changed something not knowing that I did.
Maybe it has to do something with versions?
npx -v
6.14.5
Update:
Executed different way
$ ./node_modules/.bin/cypress
/home/darius/Private/Projects/vop-live-automated-checks/node_modules/fs-extra/lib/mkdirs/make-dir.js:85
} catch {
^
SyntaxError: Unexpected token {
at new Script (vm.js:51:7)
at createScript (vm.js:136:10)
at Object.runInThisContext (vm.js:197:10)
at Module._compile (internal/modules/cjs/loader.js:618:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:665:10)
at Module.load (internal/modules/cjs/loader.js:566:32)
at tryModuleLoad (internal/modules/cjs/loader.js:506:12)
at Function.Module._load (internal/modules/cjs/loader.js:498:3)
at Module.require (internal/modules/cjs/loader.js:598:17)
at require (internal/modules/cjs/helpers.js:11:18)
at Object.<anonymous> (/home/darius/Private/Projects/vop-live-automated-checks/node_modules/fs-extra/lib/mkdirs/index.js:3:44)
at Module._compile (internal/modules/cjs/loader.js:654:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:665:10)
at Module.load (internal/modules/cjs/loader.js:566:32)
at tryModuleLoad (internal/modules/cjs/loader.js:506:12)
at Function.Module._load (internal/modules/cjs/loader.js:498:3)
Maybe this is same but full error?
If it suddenly happened, you might have switched out of bash terminal. double check.
Just deleted node_modules and ran
npm install
and now works.

Cannot find module 'fs-extra' error when launching tests despite the module is present in cypress

Just encountered the issue. After launching my tests this error appears in the cypress context window.
Can't start server
The plugins file is missing or invalid.
Your pluginsFile is set to /Users/alexanderti/WebstormProjects/klickly-autotests-js/cypress/plugins/index.js, but either the file is missing, it contains a syntax error, or threw an error when required. The pluginsFile must be a .js or .coffee file.
Please fix this, or set pluginsFile to false if a plugins file is not necessary for your project.
Error: Cannot find module 'fs-extra'
at Function.Module._resolveFilename (module.js:543:15)
at Function.Module._load (module.js:473:25)
at Module.require (module.js:586:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/Users/alexanderti/WebstormProjects/klickly-autotests-js/cypress/plugins/index.js:51:12)
at Object.<anonymous> (/Users/alexanderti/WebstormProjects/klickly-autotests-js/cypress/plugins/index.js:165:3)
at Module._compile (module.js:642:30)
at Object.Module._extensions..js (module.js:653:10)
at Module.load (module.js:561:32)
at tryModuleLoad (module.js:504:12)
at Function.Module._load (module.js:496:3)
at Module.require (module.js:586:17)
at require (internal/module.js:11:18)
at module.exports (/Users/alexanderti/Library/Caches/Cypress/3.4.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_plugins.js:118:15)
at Object.<anonymous> (/Users/alexanderti/Library/Caches/Cypress/3.4.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/index.js:9:25)
at Object.<anonymous> (/Users/alexanderti/Library/Caches/Cypress/3.4.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/index.js:11:3)
at Module._compile (module.js:642:30)
at Object.Module._extensions..js (module.js:653:10)
at Module.load (module.js:561:32)
at tryModuleLoad (module.js:504:12)
at Function.Module._load (module.js:496:3)
at Function.Module.runMain (module.js:683:10)
at startup (bootstrap_node.js:196:16)
at bootstrap_node.js:622:3
Everything worked fine until I accidentally installed fs-exta module in package.json via UI prompt in Webstorm and then uninstalled it. Also removed ./node_modules and installed back.
But the error remains.
I've checked modules availability via npm ls fs-extra and it shows that it present
─┬ cypress#3.4.0
│ └── fs-extra#5.0.0
├─┬ mochawesome-merge#2.1.0
│ └── fs-extra#7.0.1
└─┬ mochawesome-report-generator#4.1.0
└── fs-extra#7.0.1
Just add this to your package.json:
"browser": {
"fs": false
}
solved the problem for me. I also added two more to avoid more problems:
"browser": {
"fs": false,
"path": false,
"os": false
}
Fixed by re-installing node_modules directory but with package-lock.json deleted, perhaps because of this it was looking on old version. Now fixed
is that sort of solution ?
https://github.com/cypress-io/cypress/issues/21615#issuecomment-1170103810
step 1
delete the caches
step 2
reinstall cypress
and I got the old version successfully

Adding WebSocket to Webserver

I'm trying to add websocket to my webserver by simply following this guide using a Beaglebone:
https://www.w3schools.com/nodejs/nodejs_raspberrypi_webserver_websocket.asp
However, I'm getting this error:
tugbars#beaglebone:~$ sudo node webserver1.js
/home/tugbars/node_modules/ws/lib/websocket.js:347
...options
^^^
SyntaxError: Unexpected token ...
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:549:28)
at Object.Module._extensions..js (module.js:586:10)
at Module.load (module.js:494:32)
at tryModuleLoad (module.js:453:12)
at Function.Module._load (module.js:445:3)
at Module.require (module.js:504:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/home/tugbars/node_modules/ws/index.js:3:19)
I think the problem is at
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.0.3/socket.io.js"></script>
this part but I couldn't figure out how to solve it.Thanks for help.
Extra information. I have downloaded socket.io as sudo. When i type npm list socket.io, I'm getting the version of the installed socket.io. Node is also at it's last version.
You almost certainly have an outdated version of Node that doesn't have support for the spread operator (foo = { ...options }) or for destructuring (const { x, ...options } = foo). Update to a newer version of Node (12.14.1 is the latest stable release).
Also, you mention “downloading socket.io as sudo”, possibly referring to installing the node module, but you also shared an HTML script tag showing a Cloudflare hosted version. You might want to make sure you understand how you're loading that library before proceeding.

Rxjs Mocha tests will not run on WebStorm

I have been trying to get the spec tests running from the rxjs repository on the WebStorm IDE.
https://github.com/ReactiveX/rxjs.git
The issue is that I can run the tests using the included script, and manually through the command line but configuring WebStorm is not working.
Below is the error message that I am getting most frequently. I have included the default opts file for Mocha, and below is the result.
ReferenceError: asDiagram is not defined
at Suite.<anonymous> (/Users/test/Desktop/Test/rxjs/spec/Observable-spec.ts:636:3)
at Object.create (/Users/test/Desktop/Test/rxjs/node_modules/mocha/lib/interfaces/common.js:112:19)
at context.describe.context.context (/Users/test/Desktop/Test/rxjs/node_modules/mocha/lib/interfaces/bdd.js:44:27)
at Object.<anonymous> (/Users/test/Desktop/Test/rxjs/spec/Observable-spec.ts:635:1)
at Module._compile (module.js:652:30)
at Module.m._compile (/Users/test/Desktop/Test/rxjs/node_modules/ts-node/src/index.ts:430:23)
at Module._extensions..js (module.js:663:10)
at Object.require.extensions.(anonymous function) [as .ts] (/Users/test/Desktop/Test/rxjs/node_modules/ts-node/src/index.ts:433:12)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
the problem occurs because Webstorm is passing --ui bdd to mocha, overwriting your custom ui specified in spec/support/default.opts. To work out the issue, you have to change User interface: option in Mocha run configuration from default (bdd) to your custom one (spec/helpers/testScheduler-ui.ts) - field is editable, you can type/paste the value. Configuration that works fine for me:

How can I run script files by their shortcuts in Windows?

Tried naive way with a standard Windows shortcut file and with a cmd.exe, failed like this:
D:\...>node tty-checker.js.lnk
D:\...\tty-checker.js.lnk:1
(function (exports, require, module, __filename, __dirname) { L
SyntaxError: Unexpected token ILLEGAL
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:414:25)
at Object.Module._extensions..js (module.js:442:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:313:12)
at Function.Module.runMain (module.js:467:10)
at startup (node.js:136:18)
at node.js:963:3
Maybe you can suggest a way?
Amazing if there is a general method working not only for .js, but for any other source code file type too.

Resources