【问题标题】:adding styled-components to project causes. Cannot find namespace 'NodeJS'将 styled-components 添加到项目原因。找不到命名空间“NodeJS”
【发布时间】:2018-09-04 19:43:39
【问题描述】:

构建一个默认的 react-native 应用,使用 Typescript 并添加 styled-components,在应用中引用它并尝试编译会导致以下错误:

node_modules/styled-components/typings/styled-components.d.ts(116,44):错误 TS2503:找不到命名空间“NodeJS”。

请参阅 repo 以重现。 https://github.com/StevenTCramer/Issue1

【问题讨论】:

  • 请在您的问题中添加minimal reproducible example
  • @bennygenel 我已经有一个指向 GitHub 存储库的链接,其中包含一个完整且可验证的最小示例?
  • 您是否尝试安装@types/node

标签: typescript react-native styled-components


【解决方案1】:

您需要使用 npm 安装 @types/node 才能获取 NodeJS 命名空间。

$ npm install --save-dev @types/node

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-01-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-11-28
    • 2012-06-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多