Error: Cannot find module '/opt/render/project/src/index.js' with typescript

Já olhei várias correções na comunidade mas ainda não conseguir resolver o problema. Estou usando yarn.

Jan 10 09:32:52 AM  ==> Starting service with 'node index.js'
Jan 10 09:32:52 AM  internal/modules/cjs/loader.js:888
Jan 10 09:32:52 AM    throw err;
Jan 10 09:32:52 AM    ^
Jan 10 09:32:52 AM  
Jan 10 09:32:52 AM  Error: Cannot find module '/opt/render/project/src/index.js'
Jan 10 09:32:52 AM      at Function.Module._resolveFilename (internal/modules/cjs/loader.js:885:15)
Jan 10 09:32:52 AM      at Function.Module._load (internal/modules/cjs/loader.js:730:27)
Jan 10 09:32:52 AM      at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
Jan 10 09:32:52 AM      at internal/main/run_main_module.js:17:47 {
Jan 10 09:32:52 AM    code: 'MODULE_NOT_FOUND',
Jan 10 09:32:52 AM    requireStack: []

meu package. json

{
  "name": "api-student-default",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "dependencies": {
    "cors": "^2.8.5",
    "dotenv": "^16.0.3",
    "express": "^4.18.2"
  },
  "scripts": {
    "dev": "tsnd --transpile-only --respawn --ignore-watch node_modules src/server.ts",
    "build": "yarn && tsc",
    "start": "node ./dist/index.js"
  },
  "devDependencies": {
    "@types/cors": "^2.8.13",
    "@types/express": "^4.17.15",
    "ts-node-dev": "^2.0.0",
    "typescript": "^4.9.4"
  }
}

jsonconfig

{
  "compilerOptions": {
    "target": "ES2021",                                 
    "lib": [
      "esnext"
    ],                                       
    "module": "commonjs",                               
    "rootDir": "src",                                 
    "baseUrl": "./",                                
    "resolveJsonModule": true,                       
    "sourceMap": true,                            
    "outDir": "./dist",                                  
    "esModuleInterop": true,                           
    "forceConsistentCasingInFileNames": true,            
    "strict": true,                                    
    "skipLibCheck": true                             
  }
}

Dese já agradeço a atenção.

Hey,

Thanks for reaching out!

MODULE_NOT_FOUND errors imply you haven’t installed your dependencies. Either at all, (e.g. missing npm install) or that the package is in your devDependencies and you need to either move it to dependencies or include the devDependencies in your install [https://docs.npmjs.com/cli/v8/commands/npm-install#:~:text=With%20the%20--production,production%3Dfalse.]

Jérémy, Render Support

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.