English 中文(简体)
NestJs诉10 Error:Cannot没有找到电弧/应用模块。
原标题:NestJs v10 Error: Cannot find module src/app.module

我只是安装了“ Nest公司诉10”,一开始就有错误。

> nest start --watch

>  SWC  Running...
Successfully compiled: 4 files with swc (14.34ms)
Watching for file changes.
Error: Cannot find module  src/app.module 
Require stack:
- /Volumes/NestJs/dist/main.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:1075:15)
    at Function.Module._load (node:internal/modules/cjs/loader:920:27)
    at Module.require (node:internal/modules/cjs/loader:1141:19)
    at require (node:internal/modules/cjs/helpers:110:18)
    at Object.<anonymous> (/Volumes/NestJs/dist/main.js:6:20)
    at Module._compile (node:internal/modules/cjs/loader:1254:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
    at Module.load (node:internal/modules/cjs/loader:1117:32)
    at Function.Module._load (node:internal/modules/cjs/loader:958:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)

✔  TSC  Initializing type checker...
>  TSC  Found 0 issues.

http://strong>。

{
  "$schema": "https://json.schemastore.org/nest-cli",
  "collection": "@nestjs/schematics",
  "sourceRoot": "src",
  "compilerOptions": {
    "deleteOutDir": true,
    "builder": "swc",
    "typeCheck": true
  }
}

页: 1

{
  "compilerOptions": {
    "module": "commonjs",
    "declaration": true,
    "removeComments": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "allowSyntheticDefaultImports": true,
    "target": "es2017",
    "sourceMap": true,
    "outDir": "./dist",
    "baseUrl": "./",
    "incremental": true,
    "skipLibCheck": true,
    "strictNullChecks": false,
    "noImplicitAny": false,
    "strictBindCallApply": false,
    "forceConsistentCasingInFileNames": false,
    "noFallthroughCasesInSwitch": false
  }
}

I m Usnes v10.2.3 and Node v18.16

I try change "baseUrl": "./" to "baseUrl": "./src" but still not work

问题回答

It looks like the error is related to module resolution, specifically not being able to find the src/app.module module. This issue can occur due to a variety of reasons. Let s try a few steps to troubleshoot and resolve the problem:

  1. Check File Paths: Make sure that your file structure matches the import path you re using. Ensure that you have an app.module.ts file in the src directory.

  2. www.un.org/Depts/DGACM/index_spanish.htm 检查部主任: 由于你重新使用《化学武器公约》作为汇编者,确保汇编的文件在<编码>dist目录中正确生成。

  3. Check tsconfig.json Paths: In your tsconfig.json file, the "baseUrl": "./src" setting might actually be appropriate if your source code is located in the src directory. You mentioned trying this, but it s worth confirming that the path is set correctly.

    "baseUrl": "./src"
    
  4. www.un.org/Depts/DGACM/index_spanish.htm www.un.org/spanish/ga/president 确保申请的切入点(main.tsmain.js)位于src的目录中,并正确地加以配置。

  5. www.un.org/Depts/DGACM/index_spanish.htm CheckCLI: • 确保你从贵国 NestS项目根名录(nest-cli.json文档)上操作<代码>neststart。

  6. Clean and Rebuild: Sometimes, stale compiled files or cached data can cause issues. Try deleting the dist directory entirely and then run the nest start command again.

  7. www.un.org/Depts/DGACM/index_spanish.htm Update Node.js : 确保你重新使用与 yourS版本相容的Node.js版本。 虽然你提到使用Node诉18.16,但可能存在着与特定次要版本的兼容性问题。 你可以尝试使用LTS版本,如Node v16.x或 v14.x。

  8. Update NestJS: While using the latest version of NestJS is generally a good idea, sometimes there might be issues with the latest versions. You can try using a slightly earlier version of NestJS to see if the issue is version-specific.

  9. http://www.un.org。 您的项目中的通知要求也会产生解决模块的问题。 确保适当安排进口模块。

  10. Try TypeScript Compiler: If none of the above steps work, try using the TypeScript compiler instead of SWC to see if it resolves the issue.

如果你尝试所有这些步骤,并仍在处理这个问题,考虑与 Nest社区联系,或在其Gite Hub储藏处提出一个问题,因为这可能是与 NestJS诉10有关的具体堡案。





相关问题
how to have http response with pipe throwing error?

I have a nestjs application in which I created a pipe to check if value is a valid URL. If the URL is invalid, throw error. This is used in a controller to save an item into the database. I just ...

Can t set cookie in response NestJs

I Have a nestjs graphQL auth microservice and trying to set a http only cookie containing the token, and for some reason setting the cookie doesn t work, i get this error: { "errors": [ ...

store data in memory with nestjs

I am trying to persist some data in my nestjs server so I can then use that data in my client app through http requests. I have created a products.service.ts file with the function getAllData() that ...

NestJS ConfigModule not loading the correct .env file

I have 2 different file with environment variables: .env.development and .env.production. I am trying to load the correct file through the ConfigModule like so: app.module.ts @Module({ imports: [ ...

热门标签