Typescript 电脑死机后与茉莉花有关的随机错误

Typescript 电脑死机后与茉莉花有关的随机错误,typescript,configuration,jasmine,angular7,Typescript,Configuration,Jasmine,Angular7,所以我在写的一个新组件中写了一些评论,然后让我沮丧的是,我的笔记本电脑电池用完了,关机了。发生这种情况时,我的服务器正在运行 通常情况下,这没什么大不了的,我只需重新打开它,重新启动服务器,然后继续开发。这次它决定给我一些错误: 找不到名称“descripe”、和expect、和beforeach等 注:这与以下资料中概述的问题基本相同: 话虽如此,我知道从“茉莉花”中导入{}解决方法。然而,这就是我的问题的来源 以上只是一种“变通办法”。从我一直在我的网站上工作的时间,它已经完美地工作

所以我在写的一个新组件中写了一些评论,然后让我沮丧的是,我的笔记本电脑电池用完了,关机了。发生这种情况时,我的服务器正在运行

通常情况下,这没什么大不了的,我只需重新打开它,重新启动服务器,然后继续开发。这次它决定给我一些错误:

找不到名称“descripe”
、和
expect
、和
beforeach

注:这与以下资料中概述的问题基本相同:

话虽如此,我知道从“茉莉花”中导入{}解决方法。然而,这就是我的问题的来源

以上只是一种“变通办法”。从我一直在我的网站上工作的时间,它已经完美地工作,从来没有需要额外的导入规范文件。我想解决这个问题,让它在没有额外导入的情况下工作。到目前为止,在我的研究中,我不相信有人解决了这个问题

与上述问题一样,我在我的
tsconfig.json
中的
“typeroot”
下列出了
node\u modules/@types

我在项目中安装了
@types/jasmine

我现在唯一能想到的是,在
/src
目录中有单独的tsconfig文件(
/src/tsconfig.spec.json
/src/tsconfig.app.json
),而不是
/tsconfig.json
文件

在这些文件中,还有另一个
“类型”
部分,我看到一些人引用的其他
“包括”
部分

无论如何,我将包括一些配置文件供参考:

/src/tscongif.app.json

{
  "extends": "../tsconfig.json",
  "compilerOptions": {
    "outDir": "../out-tsc/app",
    "types": []
  },
  "exclude": [
    "test.ts",
    "**/*.spec.ts"
  ]
}
{
  "extends": "../tsconfig.json",
  "compilerOptions": {
    "outDir": "../out-tsc/spec",
    "types": [
      "jasmine",
      "node"
    ]
  },
  "files": [
    "test.ts",
    "polyfills.ts"
  ],
  "include": [
    "**/*.spec.ts",
    "**/*.d.ts"
  ]
}
{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "./",
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "module": "es2015",
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "importHelpers": true,
    "target": "es5",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2018",
      "dom"
    ]
  }
}
/src/tsconfig.spec.json

{
  "extends": "../tsconfig.json",
  "compilerOptions": {
    "outDir": "../out-tsc/app",
    "types": []
  },
  "exclude": [
    "test.ts",
    "**/*.spec.ts"
  ]
}
{
  "extends": "../tsconfig.json",
  "compilerOptions": {
    "outDir": "../out-tsc/spec",
    "types": [
      "jasmine",
      "node"
    ]
  },
  "files": [
    "test.ts",
    "polyfills.ts"
  ],
  "include": [
    "**/*.spec.ts",
    "**/*.d.ts"
  ]
}
{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "./",
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "module": "es2015",
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "importHelpers": true,
    "target": "es5",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2018",
      "dom"
    ]
  }
}
/tsconfig.json

{
  "extends": "../tsconfig.json",
  "compilerOptions": {
    "outDir": "../out-tsc/app",
    "types": []
  },
  "exclude": [
    "test.ts",
    "**/*.spec.ts"
  ]
}
{
  "extends": "../tsconfig.json",
  "compilerOptions": {
    "outDir": "../out-tsc/spec",
    "types": [
      "jasmine",
      "node"
    ]
  },
  "files": [
    "test.ts",
    "polyfills.ts"
  ],
  "include": [
    "**/*.spec.ts",
    "**/*.d.ts"
  ]
}
{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "./",
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "module": "es2015",
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "importHelpers": true,
    "target": "es5",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2018",
      "dom"
    ]
  }
}
如果你们想要任何其他文件,请告诉我,我会添加它们

更新


在下面的评论中,我删除了
node\u modules
文件夹并重新安装了项目。我还使用命令
npm cache verify
验证了npm的缓存。在这之后,我的问题仍然存在。

那么在笔记本电脑死机之前它还能工作?尝试删除
node\u modules
文件夹,然后再次运行
npm install
。发生了什么事?没有骰子。虽然有一秒钟,VS代码认为它找不到@angular/core/testing,但一些重启似乎解决了这个问题。我不需要删除缓存的节点文件,是吗?它在重新构建时说:
在/home/matt/.npm/node sass/4.10.0/linux-x64-64_binding.node
@MatthewStrom中找到的缓存二进制文件基本上,要么是您的
node_modules
文件夹损坏,要么是VS代码中的链接中断。这就是为什么当您删除
node\u modules
文件夹,然后运行
npm install
时。成功了。@我想您误解了,删除
node\u modules
文件夹并重新运行
npm install
并不能解决问题。我还运行了
npm cache verify
,以确保缓存干净且运行正常。