简体   繁体   中英

Error when I try to run `npm run test` in windows command prompt

I tried to run npm run test on my directory but I get an error in the terminal that says:

'.' is not recognized as an internal or external command, operable program or batch file.

I searched around but the only thing I got close to the problem is this but there's nothing there that can help me fix it.

My OS is Windows 10 and the npm version is 8.1.0 npm-run-test-error-message

Below is the content of the package.json file found inside the directory.

{
  "name": "angular-project-1",
  "version": "0.0.2",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "./node_modules/.bin/mocha ./src/spec/mocha-specs --recursive --reporter spec",
    "test:part2": "./node_modules/.bin/mocha ./src/spec/mocha-specs/part2/ --recursive --reporter spec",
    "test:part3": "./node_modules/.bin/mocha ./src/spec/mocha-specs/part3/ --recursive --reporter spec",
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "5.2.0",
    "@angular/common": "5.2.0",
    "@angular/compiler": "5.2.0",
    "@angular/core": "5.2.0",
    "@angular/forms": "5.2.0",
    "@angular/http": "5.2.0",
    "@angular/platform-browser": "5.2.0",
    "@angular/platform-browser-dynamic": "5.2.0",
    "@angular/router": "5.2.0",
    "core-js": "2.4.1",
    "rxjs": "5.5.6",
    "zone.js": "0.8.12"
  },
  "devDependencies": {
    "@angular/cli": "1.6.5",
    "@angular/compiler-cli": "5.2.0",
    "@angular/language-service": "5.2.0",
    "@phenomnomnominal/tsquery": "2.1.1",
    "@types/jasmine": "2.8.3",
    "@types/jasminewd2": "2.0.2",
    "@types/node": "6.0.60",
    "bootstrap": "3.3.7",
    "chai": "4.0.1",
    "cheerio": "1.0.0-rc.2",
    "codelyzer": "4.0.1",
    "cssom": "0.3.0",
    "typescript": "2.5.3"
  }
}

I solved it by removing the dot ( . ) located before the entry directories called /node_modules and /src .

So this was before it was fixed:

"test": "./node_modules/.bin/mocha /src/spec/mocha-specs --recursive --reporter spec",
"test:part2": "./node_modules/.bin/mocha /src/spec/mocha-specs/part2/ --recursive --reporter spec",
"test:part3": "./node_modules/.bin/mocha /src/spec/mocha-specs/part3/ --recursive --reporter spec",

And this is after it is fixed:

"test": "/node_modules/.bin/mocha /src/spec/mocha-specs --recursive --reporter spec",
"test:part2": "/node_modules/.bin/mocha /src/spec/mocha-specs/part2/ --recursive --reporter spec",
"test:part3": "/node_modules/.bin/mocha /src/spec/mocha-specs/part3/ --recursive --reporter spec",

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM