基于jhipster的nhipster服务器启动错误

发布于 2025-01-12 10:16:43 字数 1850 浏览 1 评论 0原文

我正在尝试使用 Jhipster(即 nhipster)生成基于 Angular NestJS 的应用程序。 以下是我的 jhipster 和 nodejs 版本号:

Jhipster : 7.7.0 NodeJS: 16.14.0 LTS

但是当我尝试启动服务器时出现以下错误:

错误:

/projects/nhipster/mauto/server/node_modules/ts-node/src/index.ts:240
    return new TSError(diagnosticText, diagnosticCodes)
           ^
TSError: ⨯ Unable to compile TypeScript:
src/client/header-util.ts:56:19 - error TS2552: Cannot find name 'URL'. Did you mean 'url'?

56         url = new URL('http://localhost' + url);
                     ~~~

  src/client/header-util.ts:55:32
    55     private static prepareLink(url, pageNumber, pageSize, relType): any {
                                      ~~~
    'url' is declared here.

    at createTSError (/Users/kmadasu/kishore/mnkb/projects/nhipster/mauto/server/node_modules/ts-node/src/index.ts:240:12)
    at reportTSError (/Users/kmadasu/kishore/mnkb/projects/nhipster/mauto/server/node_modules/ts-node/src/index.ts:244:19)
    at getOutput (/Users/kmadasu/kishore/mnkb/projects/nhipster/mauto/server/node_modules/ts-node/src/index.ts:360:34)
    at Object.compile (/Users/kmadasu/kishore/mnkb/projects/nhipster/mauto/server/node_modules/ts-node/src/index.ts:393:11)
    at Module.m._compile (/Users/kmadasu/kishore/mnkb/projects/nhipster/mauto/server/node_modules/ts-node/src/index.ts:439:43)
    at Module._extensions..js (node:internal/modules/cjs/loader:1155:10)
    at Object.require.extensions.<computed> [as .ts] (/Users/kmadasu/kishore/mnkb/projects/nhipster/mauto/server/node_modules/ts-node/src/index.ts:442:12)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
[nodemon] app crashed - waiting for file changes before starting...

I am trying to generate Angular NestJS based application using Jhipster i.e, nhipster.
Below is my jhipster and nodejs version numbers:

Jhipster : 7.7.0
NodeJS: 16.14.0 LTS

But I am getting the below error, when I am trying to start the server:

Error:

/projects/nhipster/mauto/server/node_modules/ts-node/src/index.ts:240
    return new TSError(diagnosticText, diagnosticCodes)
           ^
TSError: ⨯ Unable to compile TypeScript:
src/client/header-util.ts:56:19 - error TS2552: Cannot find name 'URL'. Did you mean 'url'?

56         url = new URL('http://localhost' + url);
                     ~~~

  src/client/header-util.ts:55:32
    55     private static prepareLink(url, pageNumber, pageSize, relType): any {
                                      ~~~
    'url' is declared here.

    at createTSError (/Users/kmadasu/kishore/mnkb/projects/nhipster/mauto/server/node_modules/ts-node/src/index.ts:240:12)
    at reportTSError (/Users/kmadasu/kishore/mnkb/projects/nhipster/mauto/server/node_modules/ts-node/src/index.ts:244:19)
    at getOutput (/Users/kmadasu/kishore/mnkb/projects/nhipster/mauto/server/node_modules/ts-node/src/index.ts:360:34)
    at Object.compile (/Users/kmadasu/kishore/mnkb/projects/nhipster/mauto/server/node_modules/ts-node/src/index.ts:393:11)
    at Module.m._compile (/Users/kmadasu/kishore/mnkb/projects/nhipster/mauto/server/node_modules/ts-node/src/index.ts:439:43)
    at Module._extensions..js (node:internal/modules/cjs/loader:1155:10)
    at Object.require.extensions.<computed> [as .ts] (/Users/kmadasu/kishore/mnkb/projects/nhipster/mauto/server/node_modules/ts-node/src/index.ts:442:12)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
[nodemon] app crashed - waiting for file changes before starting...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

來不及說愛妳 2025-01-19 10:16:43

“56”行的“URL”函数未正确导入到打字稿模块中。它是来自 typescript 编译器内部 dom 定义的函数。您可以找到一种方法将其导入 header-util 类。另一种方法,我要做的就是在服务器 ts-config 文件的编译器选项中启用“dom”,通过将“dom”添加到 lib 数组中,如下所示:

{
  "compilerOptions": {
   /* Basic Options */
     "typeRoots": ["node_modules/@types"],
     "target": "ES2017" /* Specify ECMAScript target version: 'ES3' (default), 
     'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */,
     "module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 
     'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
     "lib": [
          "es6",
          "dom"    /* <--- here you are */
     ]
     ...
     }

That "URL" function at your line "56" is not imported into the typescript module properly. It is a function that comes from dom definition inside the typescript compiler. You could find a way to import it into the header-util class. Another way, and what I'd do is enable "dom" in the compiler options in the ts-config file of the server, by adding "dom" to the lib array like so:

{
  "compilerOptions": {
   /* Basic Options */
     "typeRoots": ["node_modules/@types"],
     "target": "ES2017" /* Specify ECMAScript target version: 'ES3' (default), 
     'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */,
     "module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 
     'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
     "lib": [
          "es6",
          "dom"    /* <--- here you are */
     ]
     ...
     }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文