【问题标题】:angular universal Cannot find name 'expect'角通用找不到名称“期望”
【发布时间】:2019-07-06 00:09:13
【问题描述】:

我需要一些帮助。 当我运行 npm run build:ssr && npm run serve:ssr 我收到以下错误

TS2304: Cannot find name 'expect'.
TS2304: Cannot find name 'it'.
TS2304: Cannot find name 'fail'.

npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! simplestate@0.0.1 webpack:server: `webpack --config webpack.server.config.js --progress --colors`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the simplestate@0.0.1 webpack:server script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\USER\AppData\Roaming\npm-cache\_logs\2019-02-12T08_57_37_447Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! simplestate@0.0.1 build:ssr: `npm run build:client-and-server-bundles && npm run webpack:server`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the simplestate@0.0.1 build:ssr script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\USER\AppData\Roaming\npm-cache\_logs\2019-02-12T08_57_37_479Z-debug.log

【问题讨论】:

  • 在代码中搜索“expect”、“it”和“fail”等词

标签: node.js angular npm webpack


【解决方案1】:

在您的 tsconfig.json 文件中,添加以下行:

"exclude": [
    "node_modules",
    "e2e",
    "**/*.spec.ts"
  ]

这告诉编译器在编译时忽略 node_modules 和 e2e 目录以及任何 .spec 文件。我在集成 Universal 后在 Angular 8 中遇到了这个问题,这些方法可以在每个组件的规范文件中找到。

【讨论】:

    猜你喜欢
    • 2019-03-26
    • 2020-12-15
    • 2017-10-14
    • 2018-06-28
    • 2015-07-07
    • 2016-12-27
    • 2022-12-07
    • 1970-01-01
    • 2020-12-19
    相关资源
    最近更新 更多