Unable to run the generated outside of the project root folder
Description
If I package my node application into an executable and run the executable within the project root folder, it works fine. If I move the executable to another directory, it fails to start with the following error:
[email protected] ~/workspace/executables master ● ./ad-services
[email protected] ~/workspace/executables master ● npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /Users/[email protected]/workspace/executables/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/Users/sakib/workspace/executables/package.json'
Any idea why this might be happening and how can I run the executable in a different folder?
Your script wants to open package.json at some point, but you didn't explicitly include it i n your pkg config.
How do I explictly include package.json in my pkg config? This is what I have so far in my package.json
"bin": "dist/index.js",
"pkg": {
"source": ["dist/src/**/*.js"],
"assets": ["package.json"]
},
"scripts": {
"build": "tsc",
"pkg": "npm run build && pkg package.json -t host --out-dir executables"
}
Then you do not propertly refer to the snapshot filesystem. Make sure that your path to the package.json is starting with the __dirname in your script.
@sergiz what script? Where it is supposed to refer to package.json
The script that threw an error which is shown in the first post. It's not my script, I was just pointing out what the problem was.
This issue is stale because it has been open 90 days with no activity. Remove the stale label or comment or this will be closed in 5 days. To ignore this issue entirely you can add the no-stale label
This issue is now closed due to inactivity, you can of course reopen or reference this issue if you see fit.