2 months ago
I had this app since september that now fails.
The error says npm error enoent Could not read package.json: Error: ENOENT: no such file or directory, open '/app/package.json'
I've got my package.json in the root directory (always did) and it's not given any problems until now. Haven't changed anything about the settings. How may I fix this? Thank you :)
13 Replies
2 months ago
Can you check your builder and tell me if it's using Dockerfile, nixpacks or railpacks ?
Are you importing or attempting to read package.json file in your code anywhere ?
smolpaw
Can you check your builder and tell me if it's using Dockerfile, nixpacks or railpacks ?Are you importing or attempting to read package.json file in your code anywhere ?
2 months ago
Good afternoon. It's using nixpacks and yes i guess i import all the package.json files that i installed.
2 months ago
no i meant are you reading the package.json file in your code ?
For example, this is one of my project where I import the file to read the project version
Attachments
smolpaw
no i meant are you reading the package.json file in your code ?For example, this is one of my project where I import the file to read the project version
2 months ago
Ah okay, no, I am not doing that
sergiorollan
Ah okay, no, I am not doing that
2 months ago
can you post the entire error log, also the package.json file. you can redact the dependecies and any personal informations.
smolpaw
can you post the entire error log, also the package.json file. you can redact the dependecies and any personal informations.
2 months ago
error log too long so made a txt
package.json looks like this:
{
"name": "proyecto-pruebas",
"version": "1.0.0",
"main": "Actions.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"botdaemon": "supervisor WalletMaster.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"description": "",
"dependencies": {
"xx": "xx"
},
"devDependencies": {
"supervisor": "^0.12.0"
}
}
Attachments
sergiorollan
error log too long so made a txtpackage.json looks like this:{ "name": "proyecto-pruebas", "version": "1.0.0", "main": "Actions.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "botdaemon": "supervisor WalletMaster.js" }, "keywords": [], "author": "", "license": "ISC", "description": "", "dependencies": { "xx": "xx" }, "devDependencies": { "supervisor": "^0.12.0" } }
2 months ago
Okay the only thing I can think of is that the package.json isn't in the root directory of the repo
Check your repo, is the package.json at the root dir or is it inside app/package.json ?
Because the builder expects it to be in the root directory.
If it isn't then go to your service settings and set the root directory to whatever it is
Attachments
smolpaw
Okay the only thing I can think of is that the package.json isn't in the root directory of the repoCheck your repo, is the package.json at the root dir or is it inside app/package.json ?Because the builder expects it to be in the root directory.If it isn't then go to your service settings and set the root directory to whatever it is
2 months ago
I got a readme and then a directory called WalletMaster, where everything's stored. "/WalletMaster" is what I wrote in the Root Directory field you're quoting. I've had it like this from the beginning, I changed nothing, and had no issues till now. Also there are zero files or folders named "app" in the whole project so irdk
sergiorollan
I got a readme and then a directory called WalletMaster, where everything's stored. "/WalletMaster" is what I wrote in the Root Directory field you're quoting. I've had it like this from the beginning, I changed nothing, and had no issues till now. Also there are zero files or folders named "app" in the whole project so irdk
2 months ago
can you check your github repo and see if package.json exist at /WalletMaster/package.json ?. Reason being you may have accidently added a gitignore rule about json and although the file is present locally it may not be committing.
Second let me have a look at your railway deployment config which you can find if you do View logs -> Details on the most recent failed deployment and selecting Code for Configuration. Paste the json or attach it as a file.
2 months ago
sure, I attached the image of the repo where package.json is present (I also checked that the file was not empty). I tried to remove the build command (cause I saw I'd submited the node_modules folder entirely lol so no point), so I saw both jsons. They look like this:
With build command
{ "$schema": "https://railway.com/railway.schema.json", "build": { "builder": "NIXPACKS", "buildCommand": "npm install --omit=dev", "nixpacksPlan": { "providers": [ "...", "node" ] } }, "deploy": { "runtime": "V2", "numReplicas": 1, "startCommand": "npm start", "sleepApplication": true, "multiRegionConfig": { "europe-west4-drams3a": { "numReplicas": 1 } }, "restartPolicyType": "ON_FAILURE", "restartPolicyMaxRetries": 3 } }
Without
{ "$schema": "https://railway.com/railway.schema.json", "build": { "builder": "NIXPACKS", "nixpacksPlan": { "providers": [ "...", "node" ] } }, "deploy": { "runtime": "V2", "numReplicas": 1, "startCommand": "npm start", "sleepApplication": true, "multiRegionConfig": { "europe-west4-drams3a": { "numReplicas": 1 } }, "restartPolicyType": "ON_FAILURE", "restartPolicyMaxRetries": 3 } }
Attachments
sergiorollan
sure, I attached the image of the repo where package.json is present (I also checked that the file was not empty). I tried to remove the build command (cause I saw I'd submited the node_modules folder entirely lol so no point), so I saw both jsons. They look like this:With build command{ "$schema": "https://railway.com/railway.schema.json", "build": { "builder": "NIXPACKS", "buildCommand": "npm install --omit=dev", "nixpacksPlan": { "providers": [ "...", "node" ] } }, "deploy": { "runtime": "V2", "numReplicas": 1, "startCommand": "npm start", "sleepApplication": true, "multiRegionConfig": { "europe-west4-drams3a": { "numReplicas": 1 } }, "restartPolicyType": "ON_FAILURE", "restartPolicyMaxRetries": 3 } }Without{ "$schema": "https://railway.com/railway.schema.json", "build": { "builder": "NIXPACKS", "nixpacksPlan": { "providers": [ "...", "node" ] } }, "deploy": { "runtime": "V2", "numReplicas": 1, "startCommand": "npm start", "sleepApplication": true, "multiRegionConfig": { "europe-west4-drams3a": { "numReplicas": 1 } }, "restartPolicyType": "ON_FAILURE", "restartPolicyMaxRetries": 3 } }
2 months ago
Would it be possible to add me to your github repo so I can debug this then make a pull request with a fix ?
If nixpacks is the culprit, i will add a production ready Dockerfile which will be used for a consistent deployment.
2 months ago
After a bit of back on forth on discord, this issue has been resolved.
If the same issue appears again the author is welcome to contact me directly.
Status changed to Solved brody • about 2 months ago