Trying to deploy strapi CMS written in TypeScript to Railway. I know there's a JavaScript Template, annoyingly there's not a TypeScript Template and there's nothing on the docs about deployment to Railway with TypeScript.
Here's the error logs from railway. I think it might be trying to compile the JavaScript files but I've set the compiler to ignore node modules.
#13 6.049 Error: Cannot find module 'typescript'
#13 6.049 Require stack:
#13 6.049 - /app/node_modules/fork-ts-checker-webpack-plugin/lib/typescript/type-script-worker-config.js
#13 6.049 - /app/node_modules/fork-ts-checker-webpack-plugin/lib/plugin-config.js
#13 6.049 - /app/node_modules/fork-ts-checker-webpack-plugin/lib/plugin.js
#13 6.049 - /app/node_modules/fork-ts-checker-webpack-plugin/lib/index.js
#13 6.049 - /app/node_modules/@strapi/admin/webpack.config.js
#13 6.049 - /app/node_modules/@strapi/admin/utils/get-custom-webpack-config.js
#13 6.049 - /app/node_modules/@strapi/admin/utils/index.js
#13 6.049 - /app/node_modules/@strapi/admin/index.js
#13 6.049 - /app/node_modules/@strapi/strapi/lib/commands/builders/admin.js
#13 6.049 - /app/node_modules/@strapi/strapi/lib/commands/builders/index.js
#13 6.049 - /app/node_modules/@strapi/strapi/lib/commands/build.js
#13 6.049 - /app/node_modules/@strapi/strapi/bin/strapi.js
#13 6.049 at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
#13 6.049 at Function.resolve (internal/modules/cjs/helpers.js:107:19)
#13 6.049 at createTypeScriptWorkerConfig (/app/node_modules/fork-ts-checker-webpack-plugin/lib/typescript/type-script-worker-config.js:16:70)
#13 6.049 at createPluginConfig (/app/node_modules/fork-ts-checker-webpack-plugin/lib/plugin-config.js:11:82)
#13 6.049 at ForkTsCheckerWebpackPlugin.apply (/app/node_modules/fork-ts-checker-webpack-plugin/lib/plugin.js:57:63)
#13 6.049 at createCompiler (/app/node_modules/webpack/lib/webpack.js:73:12)
#13 6.049 at create (/app/node_modules/webpack/lib/webpack.js:134:16)
#13 6.049 at webpack (/app/node_modules/webpack/lib/webpack.js:158:32)
#13 6.049 at f (/app/node_modules/webpack/lib/index.js:64:16)
#13 6.049 at Object.build (/app/node_modules/@strapi/admin/index.js:60:20) {
#13 6.049 code: 'MODULE_NOT_FOUND',
#13 6.049 requireStack: [
#13 6.049 '/app/node_modules/fork-ts-checker-webpack-plugin/lib/typescript/type-script-worker-config.js',
#13 6.049 '/app/node_modules/fork-ts-checker-webpack-plugin/lib/plugin-config.js',
#13 6.049 '/app/node_modules/fork-ts-checker-webpack-plugin/lib/plugin.js',
#13 6.049 '/app/node_modules/fork-ts-checker-webpack-plugin/lib/index.js',
#13 6.049 '/app/node_modules/@strapi/admin/webpack.config.js',
#13 6.049 '/app/node_modules/@strapi/admin/utils/get-custom-webpack-config.js',
#13 6.049 '/app/node_modules/@strapi/admin/utils/index.js',
#13 6.049 '/app/node_modules/@strapi/admin/index.js',
#13 6.049 '/app/node_modules/@strapi/strapi/lib/commands/builders/admin.js',
#13 6.049 '/app/node_modules/@strapi/strapi/lib/commands/builders/index.js',
#13 6.049 '/app/node_modules/@strapi/strapi/lib/commands/build.js',
#13 6.049 '/app/node_modules/@strapi/strapi/bin/strapi.js'
#13 6.049 ]
#13 6.049 }
Configuration for TypeScript compiler.
{
"extends": "@strapi/typescript-utils/tsconfigs/server",
"compilerOptions": {
"outDir": "dist",
"rootDir": "."
},
"include": [
"./",
"./**/*.ts",
"./**/*.js",
"src/**/*.json"
],
"exclude": [
"node_modules/",
"build/",
"dist/",
".cache/",
".tmp/",
"src/admin/",
"**/*.test.*",
"src/plugins/**"
]
}
Here's the package.json which is from the typescript quickstart template.
{
"name": "aston-and-fincher-intranet-cms",
"private": true,
"version": "0.1.0",
"description": "A Strapi application",
"scripts": {
"develop": "strapi develop",
"start": "strapi start",
"build": "strapi build",
"strapi": "strapi"
},
"dependencies": {
"@strapi/plugin-graphql": "^4.9.0",
"@strapi/plugin-i18n": "4.9.0",
"@strapi/plugin-users-permissions": "4.9.0",
"@strapi/provider-upload-cloudinary": "^4.9.0",
"@strapi/strapi": "4.9.0",
"better-sqlite3": "8.0.1"
},
"author": {
"name": "George Fincher"
},
"strapi": {
"uuid": "3a5b99f5-14e8-4962-80ef-dcf9bb469d41"
},
"engines": {
"node": ">=14.19.1 <=18.x.x",
"npm": ">=6.0.0"
},
"license": "MIT"
}
I've followed the instructions on deploying with TypeScript, my tsconfig.json should be fine. I've added the additional environment variables but it seems like that has nothing to do with the error logs.
Any help would be much appreciated as I would rather not go with the JavaScript version.
Figured it out, it wasn't included in the docs, but they literally hadn't installed typescript as a dependency. Going to file an issue with Strapi now. Should've realized this sooner. Oh well 🤷♂️.
If anyone else encounters this just do an npm install typescript
. That fixed everything for me.