无法使用“npm run dev”命令解决remix JS中的“stream”错误nodeJS

问题描述 投票:0回答:1

2天前,我删除了我的node_modules文件夹以消除错误,但在重新安装该文件夹时出现了另一个更多问题。

当输入命令“npm run dev”时,这就是我在构建时立即得到的:


> dev
> remix dev --manual


 💿  remix dev

 info  building...
X [ERROR] Could not resolve "stream"

    node_modules/@firebase/database-compat/dist/index.standalone.js:8:27:
      8 │ var require$$0$1 = require('stream');
        ╵                            ~~~~~~~~

  The package "stream" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.


X [ERROR] Could not resolve "crypto"

    node_modules/@firebase/database-compat/dist/index.standalone.js:9:27:
      9 │ var require$$1$1 = require('crypto');
        ╵                            ~~~~~~~~

  The package "crypto" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.


X [ERROR] Could not resolve "assert"

    node_modules/@firebase/database-compat/dist/index.standalone.js:11:27:
      11 │ var require$$0$2 = require('assert');
         ╵                            ~~~~~~~~

  The package "assert" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.


X [ERROR] Could not resolve "net"

    node_modules/@firebase/database-compat/dist/index.standalone.js:12:27:
      12 │ var require$$1$2 = require('net');
         ╵                            ~~~~~

  The package "net" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.


X [ERROR] Could not resolve "tls"

    node_modules/@firebase/database-compat/dist/index.standalone.js:13:27:
      13 │ var require$$2$2 = require('tls');
         ╵                            ~~~~~

  The package "tls" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.


X [ERROR] Could not resolve "stream"

    node_modules/google-gax/build/src/fallbackServiceStub.js:25:25:
      25 │ const stream_1 = require("stream");
         ╵                          ~~~~~~~~

  The package "stream" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.


X [ERROR] Could not resolve "stream"

    node_modules/google-gax/build/src/paginationCalls/pageDescriptor.js:19:25:
      19 │ const stream_1 = require("stream");
         ╵                          ~~~~~~~~

  The package "stream" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.


X [ERROR] Could not resolve "stream"

    node_modules/google-gax/build/src/streamArrayParser.js:20:25:
      20 │ const stream_1 = require("stream");
         ╵                          ~~~~~~~~

  The package "stream" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.


X [ERROR] Could not resolve "stream"

    node_modules/google-gax/build/src/streamingRetryRequest.js:14:32:
      14 │ const { PassThrough } = require('stream');
         ╵                                 ~~~~~~~~

  The package "stream" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.

我只是希望没有任何问题地运行我的项目。我不知道这个错误是从哪里来的。我尝试修改我的 remix.config.js 的内容:“

/** @type {import('@remix-run/dev').AppConfig} */
export default {
  ignoredRouteFiles: ["**/.*"],
  // appDirectory: "app",
  // assetsBuildDirectory: "public/build",
  // publicPath: "/build/",
  // serverBuildPath: "build/index.js",
  external: ["remix-development-tools/index.css"],
  browserNodeBuiltinsPolyfill: {
    modules: {
      path: true,
      util: true,
      fs: true,
      os: true,
      url: true,
      http: true,
      https: true,
      events: true,
      zlib: true,
      stream: true,
      buffer: true,
      crypto: true,
      querystring: true,
      child_process: true,
      net: true,
      tls: true,
      assert: true,
      process: true,
      tty: true,
    }
  }
};

但没有任何变化。我还尝试通过执行

npm i <package name>@latest
来更改 package.json 但它没有解决错误:

{
  "name": "falc-on",
  "private": true,
  "sideEffects": false,
  "type": "module",
  "scripts": {
    "build": "remix build",
    "dev": "remix dev --manual",
    "start": "remix-serve ./build/index.js",
    "typecheck": "tsc",
    "bug-report-test": "bug-report-test.ts"
  },
  "dependencies": {
    "@playwright/test": "^1.42.1",
    "@remix-run/css-bundle": "^2.8.1",
    "@remix-run/node": "^2.8.1",
    "@remix-run/react": "^2.8.1",
    "@remix-run/serve": "^2.8.1",
    "@stripe/react-stripe-js": "^2.6.0",
    "@stripe/stripe-js": "^3.0.8",
    "@vercel/analytics": "^1.2.2",
    "@vercel/blob": "^0.22.1",
    "@vercel/postgres": "^0.7.2",
    "@vercel/speed-insights": "^1.0.10",
    "aws-sdk": "^2.1575.0",
    "axios": "^1.6.7",
    "bcrypt": "^5.1.1",
    "dotenv": "^16.3.1",
    "firebase": "^10.8.1",
    "firebase-admin": "^12.0.0",
    "firebaseui": "^6.1.0",
    "isbot": "^5.1.1",
    "jsonwebtoken": "^9.0.2",
    "jspdf": "^2.5.1",
    "jwt-decode": "^4.0.0",
    "llama-tokenizer-js": "^1.1.3",
    "lodash": "^4.17.21",
    "mammoth": "^1.7.0",
    "mock-aws-s3": "^4.0.2",
    "moment": "^2.30.1",
    "nock": "^13.5.4",
    "node-fetch": "^3.3.2",
    "nodemailer": "^6.9.12",
    "pdfjs-dist": "^4.0.379",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-dropzone": "^14.2.3",
    "react-pdf": "^7.7.1",
    "react-router": "^6.22.3",
    "react-router-dom": "^6.22.3",
    "remix-auth": "^3.6.0",
    "remix-auth-form": "^1.4.0",
    "remix-development-tools": "^4.0.5",
    "remix-utils": "^7.5.0",
    "stripe": "^14.20.0",
    "uuid": "^9.0.1"
  },
  "devDependencies": {
    "@remix-run/dev": "^2.8.1",
    "@remix-run/eslint-config": "^2.8.1",
    "@types/react": "^18.2.65",
    "@types/react-dom": "^18.2.21",
    "@types/uuid": "^9.0.8",
    "eslint": "^8.57.0",
    "ts-node": "^10.9.2",
    "tsconfig-paths": "^4.2.0",
    "typescript": "^5.4.2"
  },
  "engines": {
    "node": ">=18.0.0"
  }
}

我尝试安装流包,但控制台说:

C:\Users\adria\OneDrive\Bureau\PROJET_FALC-On\3ème_année\Code\FALC-On\remix-FALC-On\node_modules\@remix-run\dev\dist\compiler\js\compiler.js:78
    throw new Error(`It appears you're using a module that is built in to Node, but you installed it as a dependency which could cause problems. Please remove ${fakeBuiltins.join(", ")} before continuing.`);
          ^

Error: It appears you're using a module that is built in to Node, but you installed it as a dependency which could cause problems. Please remove stream before continuing.
    at createEsbuildConfig (C:\Users\adria\OneDrive\Bureau\PROJET_FALC-On\3ème_année\Code\FALC-On\remix-FALC-On\node_modules\@remix-run\dev\dist\compiler\js\compiler.js:78:11)
    at Object.create (C:\Users\adria\OneDrive\Bureau\PROJET_FALC-On\3ème_année\Code\FALC-On\remix-FALC-On\node_modules\@remix-run\dev\dist\compiler\js\compiler.js:132:8)
    at Object.create (C:\Users\adria\OneDrive\Bureau\PROJET_FALC-On\3ème_année\Code\FALC-On\remix-FALC-On\node_modules\@remix-run\dev\dist\compiler\compiler.js:61:26)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Object.watch (C:\Users\adria\OneDrive\Bureau\PROJET_FALC-On\3ème_année\Code\FALC-On\remix-FALC-On\node_modules\@remix-run\dev\dist\compiler\watch.js:69:20)
    at async Object.serve (C:\Users\adria\OneDrive\Bureau\PROJET_FALC-On\3ème_année\Code\FALC-On\remix-FALC-On\node_modules\@remix-run\dev\dist\devServer_unstable\index.js:192:17)

Node.js v20.11.0

我不知道如何执行此指令,也不知道这是否危险

The package "stream" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.

tsconfig.json:

 {
  "include": ["remix.env.d.ts", "**/*.ts", "**/*.tsx","**/*.js","**/*.jsx", "app/routes/traduction-document.tsx", "app/firebase/firebase_init.js", "app/utils/session.server.ts"],
  "compilerOptions": {
    "lib": ["DOM", "DOM.Iterable", "ES2022"],
    "isolatedModules": true,
    "esModuleInterop": true,
    "jsx": "react-jsx",
    "moduleResolution": "Bundler",
    "resolveJsonModule": true,
    "target": "ES2022",
    "strict": true,
    "allowJs": true,
    "forceConsistentCasingInFileNames": true,
    "baseUrl": ".",
    "paths": {
      "~/*": ["./app/*"]
    },
    // Remix takes care of building everything in `remix build`.
    "noEmit": true
  }
}

有人对此事有疑问吗?我有点迷失了

node.js npm web build remix.run
1个回答
0
投票

如果您的代码发生更改,则可能是您重新导入了 Remix 路由 SSR 加载器或操作所需的仅节点依赖项,但导致客户端渲染器出现问题。

© www.soinside.com 2019 - 2024. All rights reserved.