Search code examples
node.jsnpmcucumber

npm/cucumber - '.' is not recognized as an internal or external command


I have npm installed and shows version 9.2.0. When I run the command npm run test, I get the error '.' is not recognized as an internal or external command. I have also checked if the environment variables are set as well. I cannot figure out why it happens.
Below is my package.json file:

{
  "name": "udemy_cucumber",
  "version": "1.0.0",
  "description": "practice bdd suite",
  "main": "index.js",
  "scripts": {
    "test": "./node_modules/.bin/cucumber-js --require cucumber.js --require step-definitions/**/*.js -f json:cucumber_report.json --publish-quiet"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@cucumber/cucumber": "^8.11.1",
    "@playwright/test": "^1.30.0",
    "chai": "^4.3.7",
    "cucumber-html-reporter": "^5.5.0",
    "i": "^0.3.7",
    "prettier": "^2.8.4"
  }
}

My folder structure is as below:
enter image description here

Can anyone help me out find what I missed, please?


Solution

  • Found out myself. Apparently, the windows terminal accepts backslashes to recognise the folder path.
    The command will be:

    "test": ".\node_modules\.bin\cucumber-js --require cucumber.js --require step-definitions\**\*.js -f json:cucumber_report.json --publish-quiet"