vercel / pkg

Package your Node.js project into an executable
https://npmjs.com/pkg
MIT License
24.33k stars 1.02k forks source link

"config" package cannot access the directory #1959

Closed paveldhq closed 11 months ago

paveldhq commented 1 year ago

What version of pkg are you using?

5.8.0

What version of Node.js are you using?

18.13.0

What operating system are you using?

Windows

What CPU architecture are you using?

x86_64

What Node versions, OSs and CPU architectures are you building for?

default

Describe the Bug

the config package requires a directory with yml files for configs. After packing with pkg . the build-in directory is not accessible.

Expected Behavior

config directory with contents is found

To Reproduce

  1. Create a sample application using TypeScript
  2. Add config as dependency
  3. Add
... 
"pkg": {
  "targets": [
    "node18-linux-x64",
    "node18-win-x64",
    "node18-macos-arm64"
  ],
  "scripts": "dist/**/*.js",
  "outputPath": "release",
  "assets": [
    "config/*.yml"
  ]
}
...

to package.json

ParseDark commented 1 year ago

same issue. This not work. We can't debug snapshot? Just want to double check the file has been copy into snapshot

  "assets": [
      "node_modules/.prisma/client/*",
      "build/**/*",
      "public/**/*",
      "dist/**/*"
    ],

Just want to put everything dist in the snapshot.

ParseDark commented 1 year ago

same issue. This not work. We can't debug snapshot? Just want to double check the file has been copy into snapshot↳

  "assets": [
      "node_modules/.prisma/client/*",
      "build/**/*",
      "public/**/*",
      "dist/**/*"
    ],

Just want to put everything dist in the snapshot.↳

It's worked for me. I think my code file reference has some errors.

damartripamungkas commented 1 year ago

What version of pkg are you using?

5.8.0

What version of Node.js are you using?

18.13.0

What operating system are you using?

Windows

What CPU architecture are you using?

x86_64

What Node versions, OSs and CPU architectures are you building for?

default

Describe the Bug

the config package requires a directory with yml files for configs. After packing with pkg . the build-in directory is not accessible.

Expected Behavior

config directory with contents is found

To Reproduce

  1. Create a sample application using TypeScript
  2. Add config as dependency
  3. Add
... 
"pkg": {
  "targets": [
    "node18-linux-x64",
    "node18-win-x64",
    "node18-macos-arm64"
  ],
  "scripts": "dist/**/*.js",
  "outputPath": "release",
  "assets": [
    "config/*.yml"
  ]
}
...

to package.json

You can use the code below as an alternative without set path in package.json/assets :

    const { join } = require("node:path");
    const { cwd } = require("node:process");
    const { readFile } = require("node:fs/promises");
    const pathFile = join(cwd(), "config.yml");
    const getData = await readFile(pathFile, { encoding: "utf-8"});
    getData; // parse this with package like yaml
github-actions[bot] commented 12 months ago

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] commented 11 months ago

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