小编ash*_*y g的帖子

Cannot declaremodule in an NgModule as it's not a part of the current compilation Angular

Im not sure what is happening here but i am receiving this error 'Cannot declare 'FormsModule' in an NgModule as it's not a part of the current compilation' when importing 'formsModule' and 'reactiveformsmodule'into my app.module component.

I am running angular 9 and have tried clearing the cache, reinstalling npm. Could these be an angular 9 issue ? would downgrading to 8 fix the problem...

I am confused as to what is going on here as it imported fine the day …

html javascript angular angular9

17
推荐指数
2
解决办法
1万
查看次数

Package-lock.json 的构建结构很奇怪,大小加倍

嘿,当我运行 npm install 并生成我的包锁定文件时,它正在以奇怪的结构构建文件。现在,我已经与其他开发人员核实,尝试在相同的分支上模拟这一点,但他们没有遇到相同的问题。所以这一定是我本地的问题。

我最近更新了节点,但是我运行的节点版本与其他开发人员相同,但他们没有遇到问题。

节点版本 - 14.17.3 npm 版本 - 7.20.1

我一开始以为这可能是节点问题,但我们使用的是同一版本。我尝试删除 node_modules 和 json 锁并执行新的 npm i 但遇到同样的问题。

运行 npm run bundle 时,它​​似乎构建正常,但文件结构对我来说看起来很奇怪,并且行大小增加了一倍。我无法将文件的全部内容放在这里,因为它的长度超过 50,000 行。但我可以为您提供一个快照,说明该文件是如何从最初的样子到现在的样子的。

在此输入图像描述

前:

  {
  "name": "@culture-trip/header-ui-module",
  "version": "8.12.11",
  "lockfileVersion": 1,
  "requires": true,
  "dependencies": {
    "@babel/code-frame": {
      "version": "7.12.13",
      "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.12.13.tgz",
      "integrity": "sha512-HV1Cm0Q3ZrpCR93tkWOYiuYIgLxZXZFVG2VgK+MBWjUqZTundupbfx2aXarXuw5Ko5aMcjtJgbSs4vUGBS5v6g==",
      "dev": true,
      "requires": {
        "@babel/highlight": "^7.12.13"
      }
    },
    "@babel/compat-data": {
      "version": "7.13.8",
      "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.13.8.tgz",
      "integrity": "sha512-EaI33z19T4qN3xLXsGf48M2cDqa6ei9tPZlfLdb2HC+e/cFtREiRd8hdSqDbwdLB0/+gLwqJmCYASH0z2bUdog==",
      "dev": true
    },
Run Code Online (Sandbox Code Playgroud)

后:

{
  "name": "@culture-trip/header-ui-module",
  "version": "8.12.11",
  "lockfileVersion": 2,
  "requires": true,
  "packages": {
    "": { …
Run Code Online (Sandbox Code Playgroud)

javascript node.js node-modules reactjs

7
推荐指数
1
解决办法
2250
查看次数

("[object Promise]") 无法序列化为 JSON

完整错误:

错误:.bgetStaticProps“/”中返回的序列化错误。原因:( object"[object Promise]") 无法序列化为 JSON。请仅返回 JSON 可序列化数据类型。

我正在尝试调用我的函数之一,该函数从 API 端点检索一些数据,但是当尝试将此数据传递给 props 时,我收到错误。我不太确定我做错了什么,因为如果 fetch 调用在 GetStaticProps 内,则它会起作用,但我希望 fetch 调用的所有逻辑都存在于单独的 js 页面中以减少冗余,但是这样做时会创建此错误。

export async function getStaticProps() {

let b = WordpressService.getPageByIdTest(50);

return {
    props: {
        b: b,
    }, 
    revalidate: 30     
}
Run Code Online (Sandbox Code Playgroud)

}

const WordpressService = {
    async getPageByIdTest(id) {
    
        const resIndexPage = await fetch(`${url}pages/${id}`);
        const indexPageData = await resIndexPage.json();

        return indexPageData;
    }
}
Run Code Online (Sandbox Code Playgroud)

javascript http fetch reactjs

2
推荐指数
1
解决办法
1万
查看次数

标签 统计

javascript ×3

reactjs ×2

angular ×1

angular9 ×1

fetch ×1

html ×1

http ×1

node-modules ×1

node.js ×1