簡體   English   中英

Jest js node_modules\\jest\\node_modules\\jest-cli\\build\\cli\\index.js:227 } catch {

[英]Jest js node_modules\jest\node_modules\jest-cli\build\cli\index.js:227 } catch {

我在本教程中運行npm init npm i -D jest

運行nmp test后出現此錯誤

這不是來自生物.js 或生物.test.js 的錯誤,因為沒有發生此文件錯誤。 我怎樣才能解決這個問題 ? 我已經嘗試恢復 mode_modules。 我不知道這有什么問題,但我正在使用節點 8.17.0,因為我正在使用 Firebase 雲功能

PS C:\Users\Pawel\Desktop\HerosIIIJS> npm test

> heros_iii_js@1.0.0 test C:\Users\Pawel\Desktop\HerosIIIJS
> jest

C:\Users\Pawel\Desktop\HerosIIIJS\node_modules\jest\node_modules\jest-cli\build\cli\index.js:227
    } catch {
            ^

SyntaxError: Unexpected token {
at createScript (vm.js:80:10)
    at Object.runInThisContext (vm.js:139:10)
    at Module._compile (module.js:617:28)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
    at Module.require (module.js:597:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (C:\Users\Pawel\Desktop\HerosIIIJS\node_modules\jest\node_modules\jest-cli\bin\jest.js:16:3)
npm ERR! Test failed.  See above for more details.
const getProjectListFromCLIArgs = (argv, project) => {
  const projects = argv.projects ? argv.projects : [];

  if (project) {
    projects.push(project);
  }

  if (!projects.length && process.platform === 'win32') {
    try {
      projects.push((0, _jestUtil().tryRealpath)(process.cwd()));
    } catch { // <= error
      // do nothing, just catch error
      // process.binding('fs').realpath can throw, e.g. on mapped drives
    }
  }

  if (!projects.length) {
    projects.push(process.cwd());
  }

  return projects;
};

包.json

{
  "name": "heros_iii_js",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "jest"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "jest": "^26.6.2"
  }
}

文件結構:

![在此處輸入圖片說明

升級 node.js 在舊版本的 node 中,它們沒有處理 jest 文件的 catch 塊。

它將從 node -v9.11.2 開始工作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM