0

I am trying to deploy AdonisJS 5 on IIS, I am getting the following error on RunningLog folder

./RunningLog

internal/modules/cjs/loader.js:905
  throw err;
  ^

Error: Cannot find module 'C:\Server\htdocs\Adonis\whatsapp\server.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
    at Function.Module._load (internal/modules/cjs/loader.js:746:27)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
    at internal/main/run_main_module.js:17:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

This is my web.config where I am using as arguments : C:\Server\htdocs\Adonis\whatsapp\node_modules\ts-node .\server.ts However I have tried to play around changing between server.ts and server.js Also I have tried to use ts-node to no avail

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <handlers>
      <add name="httppPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
    </handlers>
    <httpPlatform stdoutLogEnabled="true" stdoutLogFile=".\RunningLog\node.log" startupTimeLimit="20" processPath="C:\Program Files\nodejs\node.exe" arguments="C:\Server\htdocs\Adonis\whatsapp\node_modules\ts-node .\server.ts">
            <environmentVariables>
                <environmentVariable name="PORT" value="%HTTP_PLATFORM_PORT%" />
                <environmentVariable name="NODE_ENV" value="Production" />
            </environmentVariables>
        </httpPlatform>
  </system.webServer>
</configuration> 

This is my package.json

{
  "name": "hello-world",
  "version": "1.0.0",
  "private": true,
  "type": "module",
  "scripts": {
    "dev": "node ace serve --watch",
    "build": "node ace build --production",
    "start": "node --experimental-specifier-resolution=node --loader ts-node/esm /server.ts",
    "lint": "eslint . --ext=.ts",
    "format": "prettier --write ."
  },
  "eslintConfig": {
    "extends": [
      "plugin:adonis/typescriptApp",
      "prettier"
    ],
    "plugins": [
      "prettier"
    ],
    "rules": {
      "prettier/prettier": [
        "error"
      ]
    }
  },
  "eslintIgnore": [
    "build"
  ],
  "prettier": {
    "trailingComma": "es5",
    "semi": false,
    "singleQuote": true,
    "useTabs": false,
    "quoteProps": "consistent",
    "bracketSpacing": true,
    "arrowParens": "always",
    "printWidth": 100
  },
  "devDependencies": {
    "@adonisjs/assembler": "^5.6.2",
    "@japa/preset-adonis": "^1.0.15",
    "@japa/runner": "^2.0.8",
    "adonis-preset-ts": "^2.1.0",
    "eslint": "^8.15.0",
    "eslint-config-prettier": "^8.5.0",
    "eslint-plugin-adonis": "^2.1.0",
    "eslint-plugin-prettier": "^4.0.0",
    "pino-pretty": "^7.6.1",
    "prettier": "^2.6.2",
    "typescript": "^4.6.4",
    "youch": "^3.2.0",
    "youch-terminal": "^2.1.4"
  },
  "dependencies": {
    "@adonisjs/core": "^5.7.6",
    "@adonisjs/repl": "^3.1.10",
    "fs": "0.0.1-security",
    "proxy-addr": "^2.0.7",
    "qrcode-terminal": "^0.12.0",
    "reflect-metadata": "^0.1.13",
    "source-map-support": "^0.5.21",
    "ts-node": "^10.7.0",
    "whatsapp-web.js": "^1.16.6"
  }
}

This is my tsconfig.json

{
  "extends": "./node_modules/adonis-preset-ts/tsconfig",
  "include": ["**/*"],
  "exclude": ["node_modules", "build"],
  "compilerOptions": {
    "esModuleInterop": true,
    "outDir": "build",
    "rootDir": "./",
    "sourceMap": true,
    "paths": {
      "App/*": ["./app/*"],
      "Config/*": ["./config/*"],
      "Contracts/*": ["./contracts/*"],
      "Database/*": ["./database/*"]
    },
    "types": ["@adonisjs/core", "@adonisjs/repl", "@japa/preset-adonis/build/adonis-typings"]
  },
    "ts-node": {
        "esm": true
    },
    "lib": ["esnext"]
}
Alejandro Jurado
  • 137
  • 1
  • 3
  • 15
  • `./server.js` is invalid, and you should use absolute path there. – Lex Li May 21 '22 at 20:26
  • The thing is I don't even have server.js, I have server.ts how to run typescript on node iis – Alejandro Jurado May 22 '22 at 14:16
  • 1
    No one can guide you better than the official documentation, https://docs.adonisjs.com/guides/deployment#compiling-typescript-to-javascript You need to run `npm run build` or `yarn build` to generate the files for deployment in the `build` folder, and then deploy everything from there (where `server.js` should be generated. – Lex Li May 22 '22 at 16:40
  • I totally skipped the step to compile the TypeScript, now I am getting the following error: 36mlisten EACCES: permission denied 1..1.1.1:80 My IIS site is binded to a host, I know it will work on ports above 8000 but I really need port 80, feel free to post your comment as an answer and I'll upvote it! – Alejandro Jurado May 23 '22 at 01:30

0 Answers0