I came here after some hours of reading and getting into the cyclic cool deployment process. https://www.cyclic.sh/
I was trying to host my express js app for free and linked my github repo to my cyclic.sh dashboard. (I added typescript to my express app btw) The build process of my app was successful ✅ , but when I check the logs on runtime it throws me this error: ERROR: Failed to run 'node index.js'
Successful build: enter image description here
The complete error log in runtime:
2023-01-09 01:21:26.063: grep: /var/task/package.json: No such file or directory
2023-01-09 01:21:26.527: node:internal/modules/cjs/loader:998
throw err;
^
Error: Cannot find module 'dotenv'
Require stack:
- /var/task/index.js
at Module._resolveFilename (node:internal/modules/cjs/loader:995:15)
at Module._load (node:internal/modules/cjs/loader:841:27)
at Module.require (node:internal/modules/cjs/loader:1061:19)
at require (node:internal/modules/cjs/helpers:103:18)
at Object.<anonymous> (/var/task/index.js:33:34)
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) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/var/task/index.js' ]
}
Thrown at:
at Module._resolveFilename (node:internal/modules/cjs/loader:995:15)
at Module._load (node:internal/modules/cjs/loader:841:27)
at Module.require (node:internal/modules/cjs/loader:1061:19)
2023-01-09 01:21:26.527: at require (node:internal/modules/cjs/helpers:103:18)
at /var/task/index.js:33:34
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 executeUserEntryPoint (node:internal/modules/run_main:81:12)
Node.js v18.12.1
2023-01-09 01:21:26.562:
ERROR: Failed to run 'node index.js'.
Exited with code: 1
I noticed that the problem is that cyclic is not running node in the correct directory. The correct command executed should be: node dist/index.js
. Because of that, I added the scripts configuration in my package.json
as it is specified in https://docs.cyclic.sh/overview/launch, but for some reason cyclic is not reading that change in my scripts. (It works well locally)
I am not sure if I am missing something. I am very close, but I am stock at this point. I attatched some screenshots about the successful build, the failure and my package.json configuration.
My package.json file configuration: enter image description here
Any help would be very appreaciated! Thanks in advance!
Same here. I use src/index.js
and that's what in my package.json
:
"main": "src/index.js",
...
"scripts": {
"start": "node src/index.js"
},
Environments > Build paths > Output Path: leave it empty, not dist/
nor src/
, just empty. Output Path is used to build your app from, the folder where all you libs like node_mobules
are kept.
After that re-deploy if needed.