pkg icon indicating copy to clipboard operation
pkg copied to clipboard

Unable to run the generated outside of the project root folder

Open ssh24 opened this issue 6 years ago • 7 comments

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?

ssh24 avatar Apr 03 '20 17:04 ssh24

Your script wants to open package.json at some point, but you didn't explicitly include it i n your pkg config.

sergejostir avatar Apr 09 '20 12:04 sergejostir

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"
  }

ssh24 avatar Apr 09 '20 13:04 ssh24

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.

sergejostir avatar Apr 09 '20 18:04 sergejostir

@sergiz what script? Where it is supposed to refer to package.json

LeonardoRick avatar Feb 08 '21 20:02 LeonardoRick

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.

sergejostir avatar Feb 09 '21 10:02 sergejostir

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

github-actions[bot] avatar May 11 '21 00:05 github-actions[bot]

This issue is now closed due to inactivity, you can of course reopen or reference this issue if you see fit.

github-actions[bot] avatar May 16 '21 00:05 github-actions[bot]