2

I have created an express app using the express-generator like this: express work-callendar.I haven't changed anything.Now I want to pack it using the pkg command so I created the following script in my package.json

 "package":"pkg .-t latest-linux-x64 -o ./app ./app.js"

However when I run that script I get the following error

Not more than one entry file/directory is expected

Any ideas how can I resolve it?

Here is my package.json:

{
  "name": "work-calendar",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "start": "node ./bin/www",
    "package":"pkg .-t latest-linux-x64 -o ./app ./app.js"
  },
  "dependencies": {
    "body-parser": "~1.18.2",
    "cookie-parser": "~1.4.3",
    "debug": "~2.6.9",
    "express": "~4.15.5",
    "morgan": "~1.9.0",
    "pug": "2.0.0-beta11",
    "serve-favicon": "~2.4.5"
  },
  "devDependencies": {
    "pkg": "^4.3.1"
  }

Let me know if I should add anything more to the question

Muhammad Faizan
  • 1,709
  • 1
  • 15
  • 37
Manos Kounelakis
  • 2,848
  • 5
  • 31
  • 55

1 Answers1

4

I was unable to recreate your scenario. My package.json looks like this.

Node.js Version

  • 8.10

package file

{
    "name": "pkg-test",
    "version": "0.0.0",
    "private": true,
    "scripts": {
        "start": "node ./bin/www",
        "pkg": "pkg --target=latest-linux-x64 -o app.out app.js"
    },
    "dependencies": {
        "cookie-parser": "~1.4.3",
        "debug": "~2.6.9",
        "express": "~4.16.0",
        "http-errors": "~1.6.2",
        "jade": "~1.11.0",
        "morgan": "~1.9.0"
    },
    "devDependencies": {
        "pkg": "^4.3.1"
    }
}

Its better to include all your dependencies in package.json. Although I had it installed globally.

Command

> npm i --save-dev pkg
> npm run pkg

Success

app.out was created at the root of my project.

Muhammad Faizan
  • 1,709
  • 1
  • 15
  • 37