Skip to content
This repository has been archived by the owner on Jan 13, 2024. It is now read-only.

ENOENT when trying to use path.join on 4.3.0 #366

Closed
AxelTerizaki opened this issue Mar 4, 2018 · 8 comments
Closed

ENOENT when trying to use path.join on 4.3.0 #366

AxelTerizaki opened this issue Mar 4, 2018 · 8 comments
Labels

Comments

@AxelTerizaki
Copy link

AxelTerizaki commented Mar 4, 2018

Hello.

I recently upgraded pkg to 4.3.0 and ran into an issue with my project. I retested with 4.2.6 and the error doesn't seem to be here.

Basically my code outputs :
Error: ENOENT: no such file or directory, copyfile 'D:\snapshot\toyundamugen-app\dist\_player\assets\input.conf' -> 'D:\dev\toyundamugen-app\app\temp\input.conf'

While trying to copy a file using fs-extra's copy.
This is the bit of code that's used. As you can see I use (path).join for something that's inside the assets option in my package.json file.

		join(__dirname, '/_player/assets/input.conf'),
		resolve(appPath, config.PathTemp, 'input.conf'),
		{ overwrite: true }
	);

As I said, this doesn't seem to work anymore since 4.3.0-beta.1

I couldn't test with beta.0 since node builds weren't available for download anymore with that version.

If I can help with more information, please do tell me :)

@fauxilla
Copy link

I have exactly the same issue.

suppose my transpiled entry is project/dist/index.js, and I want to package project/config.json,

in my package.json I have "assets": "config.json"

but code like fs.copyFile(path.resolve(__dirname, '../config.json'), dest) throws ENOENT.

The readme [is a bit weird] where it says to use path.join(__dirname, '../path/to/asset'). Like I would've expected that to be either path.join(__dirname, 'path/to/asset') or path.resolve(__dirname, '../path/to/asset') or something.

Regardless, I've tried many variations of the above to no avail.

running pkg with --debug shows nothing suspicious, it says the file in question is queued, then packaged as an asset.

Is there any easy way to see what's actually packaged in an executable ? Would be handy to see. Even listing them in debug output at the end would be good.

I'd never tried 4.2.6 previously, but I tried reverting and got a bunch of x is not a function errors which have something to do with babel imports. Known issue with 4.2.6.

@paulmowat
Copy link

I also have the exact same issue as the original poster has raised. I was originally using 4.3.0, but once reverted back to 4.2.6 I now no longer get the error.

@AxelTerizaki
Copy link
Author

@fauxilla for your babel imports, I don't know exactly what you mean but my project uses babel as well and I have no issues with pkg 4.2.6.

Here's how I do it :

  • I build my app in a dist directory : babel --source-maps --copy-files -d dist/ src/ ( my app source is in src/ obviously)
  • My pkg section in package.json looks like that :
  "pkg": {
    "scripts": [
      "node_modules/image-size/lib/types/*.js",
      "node_modules/sqlite3/node_modules/node-pre-gyp/lib/*.js",
      "node_modules/sqlite3/node_modules/node-pre-gyp/lib/util/*.js*",
      "dist/**/*.js"
    ],
    "assets": [
      "dist/_common/db/*",
      "dist/_common/locales/*",
      "dist/_player/assets/*",
      "dist/_webapp/ressources/views/**",
      "dist/_webapp/ressources/css/*",
      "dist/_webapp/ressources/img/*",
      "dist/_webapp/vendors/css/*",
      "dist/_webapp/vendors/fonts/**",
      "dist/**/*.js",
      "dist/VERSION",
      "dist/_dashboard/**",
      "node_modules/**/*"
    ]

I'm sure this isn't the most optimized way of doing it but it works so I'm not going to complain. I'll probably try to rework the assets section sometime when I have some time to spare but my .exe works fine so far (even if a bit bloated)

@jsonmaur
Copy link

Same issue here. Trying to copy assets from the snapshot filesystem to the real filesystem will throw this error in all versions beyond 4.2.4 for me. This breaks anything having to do with initialization, creating boilerplate files, etc.

@AxelTerizaki
Copy link
Author

I tried with 4.3.3 and it still doesn't work :/

@AxelTerizaki
Copy link
Author

One workaround was found in #420 which is a similar issue.

I tried it and it worked fine for me, but thi sis still a nasty bug.

@github-actions
Copy link

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 github-actions bot added the Stale label Apr 23, 2021
@github-actions
Copy link

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants