KCGD
KCGD

Reputation: 755

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

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.

Upvotes: 10

Views: 13414

Answers (2)

Zîcu Ioan
Zîcu Ioan

Reputation: 81

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.

Upvotes: 0

KCGD
KCGD

Reputation: 755

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

Upvotes: 20

Related Questions