R
Railwayβ€’2y ago
zerosodium

NX Monorepo with Railway

Hi again ya'll and happy friday πŸ™‚ I am building a monorepo with nx and want to deploy to railway. You can reference my folder structure in the attached image. I want to deploy the cron packag to railway and setup custom build and start commands like so
npm run build:cron
npm run start:cron
npm run build:cron
npm run start:cron
but I see the build is failing. any help appreciated πŸ™‚
15 Replies
Percy
Percyβ€’2y ago
Project ID: 95ddbf08-40f9-41d9-8325-2d4614012abc
zerosodium
zerosodiumOPβ€’2y ago
95ddbf08-40f9-41d9-8325-2d4614012abc
zerosodium
zerosodiumOPβ€’2y ago
max's nx monorepo - Pastebin
Pastebin.pl is a website where you can store code/text online for a set period of time and share to anybody on earth
zerosodium
zerosodiumOPβ€’2y ago
update - figured out the build issues but seems like one of my packages is having an issue calling a function from another package. in my export package I have
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isEven = void 0;
var isEven = function (n) {
console.log("isEven");
};
exports.isEven = isEven;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isEven = void 0;
var isEven = function (n) {
console.log("isEven");
};
exports.isEven = isEven;
and in the package I am importing the function I have
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
// @ts-ignore
var utils_1 = require("utils");
(0, utils_1.isEven)(2);
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
// @ts-ignore
var utils_1 = require("utils");
(0, utils_1.isEven)(2);
𝔾𝕦𝕀π•₯𝕒𝕧𝕠 π•Šπ•”π•™π•šπ•‘
glad to see the lockfile resolved, on the other issue however, I will need to see why it cant import it
zerosodium
zerosodiumOPβ€’2y ago
these are the deploy logs that I think you might find relevant:
TypeError: (0 , utils_1.isEven) is not a function
ο»Ώat Object.<anonymous> (/app/dist/index.js:5:20)
ο»Ώat Module._compile (node:internal/modules/cjs/loader:1159:14)
ο»Ώat Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
ο»Ώat Module.load (node:internal/modules/cjs/loader:1037:32)
ο»Ώat Module._load (node:internal/modules/cjs/loader:878:12)
ο»Ώat Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
ο»Ώat node:internal/main/run_main_module:23:47
TypeError: (0 , utils_1.isEven) is not a function
ο»Ώat Object.<anonymous> (/app/dist/index.js:5:20)
ο»Ώat Module._compile (node:internal/modules/cjs/loader:1159:14)
ο»Ώat Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
ο»Ώat Module.load (node:internal/modules/cjs/loader:1037:32)
ο»Ώat Module._load (node:internal/modules/cjs/loader:878:12)
ο»Ώat Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
ο»Ώat node:internal/main/run_main_module:23:47
it's so weird though, like my start command run fines in local and prints a test string but not in prod πŸ˜”
𝔾𝕦𝕀π•₯𝕒𝕧𝕠 π•Šπ•”π•™π•šπ•‘
thats odd is it as a dev dependency? simple thing I know, but still, maybe that is a issue
zerosodium
zerosodiumOPβ€’2y ago
"dependencies": {
"utils": "*"
},
"devDependencies": {
"ts-node": "^10.9.1",
"typescript": "^5.1.3"
}
"dependencies": {
"utils": "*"
},
"devDependencies": {
"ts-node": "^10.9.1",
"typescript": "^5.1.3"
}
could that be the reason why?
𝔾𝕦𝕀π•₯𝕒𝕧𝕠 π•Šπ•”π•™π•šπ•‘
it shouldnt be
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var utils_1 = require("utils");
utils_1.isEven(2);
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var utils_1 = require("utils");
utils_1.isEven(2);
@zerosodium did the typescript ignore somehow screw it up
zerosodium
zerosodiumOPβ€’2y ago
it still works in dev, but more concerned that my build command:
"build": "tsc src/index.ts --outDir dist",
"build": "tsc src/index.ts --outDir dist",
keeps transpiling it incorrectly
zerosodium
zerosodiumOPβ€’2y ago
neg, but could it be a tsconfig issue? I actually dont even have a tsconfig now that I look but not sure it matters?
𝔾𝕦𝕀π•₯𝕒𝕧𝕠 π•Šπ•”π•™π•šπ•‘
It might actually does, as there might be a default generated at deployment
zerosodium
zerosodiumOPβ€’2y ago
I have this tsconfig as a starter but still the same results
{
"compilerOptions": {
"module": "NodeNext",
"moduleResolution": "NodeNext",
"target": "ES2020",
"sourceMap": true,
"outDir": "/dist",
"composite": true
},
"include": ["src/**/*"]
}
{
"compilerOptions": {
"module": "NodeNext",
"moduleResolution": "NodeNext",
"target": "ES2020",
"sourceMap": true,
"outDir": "/dist",
"composite": true
},
"include": ["src/**/*"]
}
any tips would be so so appreicated
𝔾𝕦𝕀π•₯𝕒𝕧𝕠 π•Šπ•”π•™π•šπ•‘
I am not sure why this is happening, I never had this (probrably because I have a laravel project with Vue), but still quite weird because in the times I did use TS I never had that type of error could you investigate the compiled javascript? as it compiles/translates it to javascript
Want results from more Discord servers?
Add your server