![](/img/trans.png)
[英]Why are Hundreds of json files in the node_modules/.cache/babel-loader folder in a react app?
[英]Why is my app getting this error when I run it, “ERROR in ./node_modules/@nestjs/common/cache/cache.providers.js”?
設置應用程序很容易。 我剛剛用 'ng new [app name]' 創建了它。 我添加了 angular 材料。 我還通過 'ng add @nestjs/ng-universal 添加了 Nestjs 的 Angular 通用服務器。 我了解到我需要確保我沒有使用 Angular 10 的 CLI,所以我用 Angular 9 的 CLI 重新進行了所有操作,它一直在工作,直到我創建了 ZC31C335EF37283C451B18BA0DD37 服務。 在我創建服務、向該服務中添加一個 HttpClient 並在組件中使用該服務后,我開始收到導致應用程序崩潰的錯誤。
npm run dev:ssr
> fullstack-flip8@0.0.0 dev:ssr /Users/jeremy/MEGA/projects/FlipIt/fullstack-flip8
> ng run fullstack-flip8:serve-ssr
****************************************************************************************
This is a simple server for use in testing or debugging Angular applications locally.
It hasn't been reviewed for security issues.
DON'T USE IT FOR PRODUCTION!
****************************************************************************************
chunk {main} main.js, main.js.map (main) 323 kB [initial] [rendered]
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 141 kB [initial] [rendered]
chunk {runtime} runtime.js, runtime.js.map (runtime) 6.15 kB [entry] [rendered]
chunk {styles} styles.css, styles.css.map (styles) 84.6 kB [initial] [rendered]
chunk {vendor} vendor.js, vendor.js.map (vendor) 5.39 MB [initial] [rendered]
Date: 2020-07-20T17:37:04.757Z - Hash: 10e58d11f5f9b0ff406f - Time: 16897ms
WARNING in ./node_modules/@nestjs/common/utils/load-package.util.js 8:39-59
Critical dependency: the request of a dependency is an expression
ERROR in ./node_modules/@nestjs/common/cache/cache.providers.js
Module not found: Error: Can't resolve 'cache-manager' in '/Users/jeremy/MEGA/projects/FlipIt/fullstack-flip8/node_modules/@nestjs/common/cache'
Hash: d01fed6a10d4859462d7
Time: 24111ms
Built at: 07/20/2020 11:37:08 AM
Asset Size Chunks Chunk Names
main.js 13.7 MiB main [emitted] [big] main
main.js.map 14.8 MiB main [emitted] [dev] main
Entrypoint main [big] = main.js main.js.map
chunk {main} main.js, main.js.map (main) 12.7 MiB [entry] [rendered]
WARNING in ./node_modules/@nestjs/core/helpers/optional-require.js 5:39-59
Critical dependency: the request of a dependency is an expression
WARNING in ./node_modules/@nestjs/core/helpers/load-adapter.js 8:39-63
Critical dependency: the request of a dependency is an expression
WARNING in ./node_modules/mongoose/lib/index.js 11:28-64
Critical dependency: the request of a dependency is an expression
WARNING in ./node_modules/@nestjs/common/utils/load-package.util.js 8:39-59
Critical dependency: the request of a dependency is an expression
WARNING in ./node_modules/require_optional/index.js 82:18-42
Critical dependency: the request of a dependency is an expression
WARNING in ./node_modules/require_optional/index.js 90:20-44
Critical dependency: the request of a dependency is an expression
WARNING in ./node_modules/require_optional/index.js 97:35-67
Critical dependency: the request of a dependency is an expression
WARNING in ./node_modules/mongodb/lib/operations/connect.js
Module not found: Error: Can't resolve 'mongodb-client-encryption' in '/Users/jeremy/MEGA/projects/FlipIt/fullstack-flip8/node_modules/mongodb/lib/operations'
this.debug is not a function
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! fullstack-flip8@0.0.0 dev:ssr: `ng run fullstack-flip8:serve-ssr`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the fullstack-flip8@0.0.0 dev: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! /Users/jeremy/.npm/_logs/2020-07-20T17_37_12_756Z-debug.log
我不知道它是否使用了服務、HttpClient 或其他東西。
使用“修復”分支。 我將做一些故障排除測試。
通過安裝幾個軟件包(見下文),我能夠讓它在您的修復分支上運行。 我看到的前幾個錯誤是Module not found errors
。 不確定為什么沒有安裝這些軟件包,或者您是否正在使用一些應該安裝它們的庫?
npm i --save-dev mongoose
npm i --save-dev cache-manager
安裝這些后,我能夠運行 ng serve 而沒有錯誤。 npm run start
,如 package.json 中所述。 但是,在那之后我遇到了運行時錯誤。
bare.js:20 Uncaught ReferenceError: process is not defined
at Object../node_modules/cli-color/bare.js (bare.js:20)
at __webpack_require__ (bootstrap:79)
at Object../node_modules/cli-color/index.js (index.js:5)
at __webpack_require__ (bootstrap:79)
at Object../node_modules/@nestjs/common/services/logger.service.js (logger.service.js:5)
at __webpack_require__ (bootstrap:79)
at Object../node_modules/@nestjs/common/decorators/core/set-metadata.decorator.js (set-metadata.decorator.js:3)
at __webpack_require__ (bootstrap:79)
at Object../node_modules/@nestjs/common/decorators/core/index.js (index.js:12)
at __webpack_require__ (bootstrap:79)
在谷歌快速搜索后,我發現了這個 stackoverflow 帖子: Angular 6 - 嘗試為應用程序提供服務時未定義進程
將以下內容應用於polyfills.ts似乎可以解決運行時問題。 現在一切都在運行。 我不熟悉 Angular CLI 的這種類型的設置。 那么可能有更好的方法來修復進程未定義錯誤呢?
(window as any).global = window;
global.Buffer = global.Buffer || require('buffer').Buffer;
global.process = require('process');
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.