Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to run the generated outside of the project root folder #884

Open
ssh24 opened this issue Apr 3, 2020 · 3 comments
Open

Unable to run the generated outside of the project root folder #884

ssh24 opened this issue Apr 3, 2020 · 3 comments

Comments

@ssh24
Copy link

@ssh24 ssh24 commented Apr 3, 2020

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:

 sakib@ibm.com  ~/workspace/executables   master ●  ./ad-services 
 sakib@ibm.com  ~/workspace/executables   master ●  npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /Users/sakib@ibm.com/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?

@sergiz
Copy link

@sergiz sergiz commented Apr 9, 2020

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

@ssh24
Copy link
Author

@ssh24 ssh24 commented Apr 9, 2020

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"
  }
@sergiz
Copy link

@sergiz sergiz commented Apr 9, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.