nodejs pkg - property 'bin' does not exist in package.json

Viewed 4079

i'm using PKG to build a program using package.json. I included the "pkg" property in package.json but pkg always returns Error! Property 'bin' does not exist in [path to package.json]

when i add the bin property it asks for the directory for the path to bin, i tried giving it the path the .bin folder in node_modules (which does make the error go away), however the generated executable just crashes immidiatley with no error. I havent found this error anywhere else.

2 Answers

Setting the property "bin" to "./main.js" (the program's entrypoint) seems to have fixed the problem. package.json:

{
  "name": "project-name",
  "version": "1.0.0",
  "description": "",
  "main": "./main.js",
  "bin": "./main.js",
  "scripts": {
    "start": "node ."
  }
}

I had similar issue transpiling TS to JS. The problem was related to the folder structure: src/ts/main.ts meanwhile in package.json the main point was bin/main.js, so after JS generation there was any main.js in bin folder.

Related