I tried to launch first example from official documentation here
https://github.com/cucumber/cucumber-js/blob/master/docs/nodejs_example.md
I used Windows 7x64 bit , node.js 6.11
I tried the following commands and got the same result
*
node_modules/cucumber/bin/cucumber.js autotests/cucumber-test/features/documentation.feature
node_modules\cucumber\bin\cucumber.js autotests\cucumber-test\features\documentation.feature
cucumber autotests\cucumber-test\features\documentation.feature
cucumber-js autotests\cucumber-test\features\documentation.feature
*
and I got the following error
cucumber.js:2
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
^^^^^^^
SyntaxError: missing ) after argument list
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at getDefinitions (<path>\node_modules\cucumber\lib\cucumber\cli\profiles_loader.js:8:23)
I also tried to downgrade to cucumber 1.3.3 but it doesn't help
Please try below command:
node_modules\cucumber\bin\cucumber.js.cmd autotests\cucumber-test\features\documentation.feature
I found solution
1) npm init -> and define package.json
2) npm install cucumber#latest
3) node_modules\.bin\cucumber.js.cmd <path>\myfeature.feature
Related
Yo guys!
I get early a job on a legacy app, using gulpjs
After having installed all dependencies, when I try execute the application with "gulp server", get the following error at console:
D:\scripts\node_modules\gulp-sass\index.js:186
).toString();
^
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> (D:\Playkids\playkids-simple-pages\scripts\tasks\development.js:4:12)
I tried to run this example on my ubuntu os.
https://github.com/google/zx/blob/main/examples/basics.mjs
after I installed zx from npm
via npm i -g zx
and run the following cmd:
sudo zx ./script.mjs
i got below error:
/usr/local/lib/node_modules/zx/zx.mjs:17
import {basename, dirname, extname, join, parse, resolve} from 'path'
^
SyntaxError: Unexpected token {
at Module._compile (internal/modules/cjs/loader.js:723:23)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)
My npm version is : 7.14.0
As exlained in above comments:
The issue originated from an old version node that didn't recognize the import feature. which is available only since : v13+ ( see https://stackoverflow.com/questions/39436322/node-js-syntaxerror-unexpected-token-import)
Find Visual Studio Code application where I tried to run the file. Things look fine but it says cannot find module. Find my terminal output below along with screenshot in "Node Program"
F:\Git Clone\Node.js_From 31Oct2019\IBM-Developer\Node.js\Course\Unit-6>node server.js
internal/modules/cjs/loader.js:638
throw err;
^
Error: Cannot find module 'sqlite3'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (F:\Git Clone\Node.js_From 31Oct2019\IBM-Developer\Node.js\Course\Unit-6\utils\utils.js:23:17)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
Node Program
You have to run npm i and then restart your application and vs code.
Install NPM by typing npm i and then restart your application
When I run ng with any command, then causes
ng -v
C:\nodejs\node_modules\#angular\cli\models\config\config.js:16
constructor(_configPath, schema, configJson, fallbacks = []) {
^
SyntaxError: Unexpected token =
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 Object.<anonymous> (C:\nodejs\node_modules\#angular\cli\models\config.js:3:18)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
node -v
v6.10.0
npm -v
4.4.1
I tried reinstalling the node, npm and #angular/cli. No solution has helped.
#Edited, Solution
I deleted ng, ng.cmd from C:\nodejs\ and folders #angular/cli/, angular-cli/ fromC:\nodejs\node_modules, and reinstall #angular/cli, and then
works correctly.
I am trying to run 'node server.js' to connect my raspberry pi device to Azure via the Azure IoT Hub. When I run the command 'node server.js', I receive the following error. Please note that I replaced my computer's user name with 'username'. The file connection_string.js does not have my computer's username in it, despite the error saying that it does. Please see error below:
SyntaxError: Invalid flags supplied to RegExp constructor '*username*'
at new RegExp (native)
at Object.<anonymous> (/Users/*username*/iot-hub-c-raspberrypi-getstartedkit/command_center_node/node_modules/azure-iot-common/lib/connection_string.js:9:31)
at Module._compile (module.js:409:26)
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 Object.<anonymous> (/Users/*username*/iot-hub-c-raspberrypi-getstartedkit/command_center_node/node_modules/azure-iot-common/common.js:15:21)
at Module._compile (module.js:409:26)
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 Object.<anonymous> (/Users/*username*/iot-hub-c-raspberrypi-getstartedkit/command_center_node/server.js:7:15)
Thank you in advance for your help!
Not sure if it is your case or not, but I had similar issue:
SyntaxError: Invalid flags supplied to RegExp constructor 'u'
I fixed it simply by updating Node.js.
Previous version was:
$ node -v
v5.1.1
Then I did:
$ curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
... long output
$ sudo apt-get install -y nodejs
... shorter output
$ node -v
v6.7.0
And no more issues.