Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnhandledPromiseRejectionWarning: Error: spawn /Users/user/template/node_modules/esbuild-dev-server/lib/../../esbuild-dev-server-darwin-x64/devserver EACCES #1

Open
uns3t opened this issue Nov 17, 2021 · 7 comments
Labels
bug Something isn't working

Comments

@uns3t
Copy link

uns3t commented Nov 17, 2021

when i use this plugin, an error occurred

(node:63759) UnhandledPromiseRejectionWarning: Error: spawn /Users/react-esbuild-template/node_modules/esbuild-dev-server/lib/../../esbuild-dev-server-darwin-x64/devserver EACCES
    at Process.ChildProcess._handle.onexit (internal/child_process.js:269:19)
    at onErrorNT (internal/child_process.js:467:16)
    at processTicksAndRejections (internal/process/task_queues.js:82:21)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:63759) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:63759) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

and esbuild code is:

const esbuild = require('esbuild');
const { lessLoader } = require('esbuild-plugin-less');
const { htmlPlugin } = require('@craftamap/esbuild-plugin-html');
const esBuildDevServer = require("esbuild-dev-server")

const htmlPluginOptions = {
    files: [
        {
            entryPoints: [
                'src/app.tsx',
            ],
            filename: 'index.html',
            htmlTemplate: `
                <!DOCTYPE html>
                <html lang="en">
                <head>
                    <meta charset="UTF-8">
                    <meta name="viewport" content="width=device-width, initial-scale=1.0">
                    <title>React-esbuild-template</title>
                </head>
                <body>
                    <div id="root">
                    </div>
                </body>
                </html>
            `,
        },
    ]
}

const options = {
    entryPoints: ['src/app.tsx'],
    bundle: true,
    metafile: true, // needs to be set
    outdir: 'dist/', // needs to be set
    plugins: [
        htmlPlugin(htmlPluginOptions),
        lessLoader()
    ],
    loader: {
        '.ts': 'ts',
    },
}

esBuildDevServer.start(
        esbuild.build(options),
        {
            port:      "10002", // optional, default: 8080
            watchDir:  "src", // optional, default: "src"
            index:     "dist/index.html", // optional
            staticDir: "dist", // optional
            onBeforeRebuild: {}, // optional
            onAfterRebuild:  {}, // optional
        }
)

@Falldot
Copy link
Owner

Falldot commented Nov 17, 2021

Hello. Thank you for contacting.

esbuild-dev-server calling rebuild repeatedly with the same options.
esbuild requires incremental: true property in options for this.
Read more: https://esbuild.github.io/api/#incremental

Add this property to the options and try again.

const options = {
    entryPoints: ['src/app.tsx'],
    bundle: true,
    metafile: true, // needs to be set
    outdir: 'dist/', // needs to be set
    incremental: true, // !important
    plugins: [
        htmlPlugin(htmlPluginOptions),
        lessLoader()
    ],
    loader: {
        '.ts': 'ts',
    },
}

@Falldot Falldot pinned this issue Nov 17, 2021
@nikolamus
Copy link

I get the same error, and I made sure to use incremetal: true

esBuildDevServer.start(build({
  sourcemap: true,
  entryPoints: ['src/index.tsx'],
  bundle: true,
  outdir: 'build',
  platform: 'browser',
  minify: true,
  keepNames: true,
  target: 'es6',
  plugins: [
    lessLoader(),
  ],
  metafile: true,
  incremental: true,
}), {
  port:      '3000',
  watchDir:  'src',
  index:     'build/index.html',
  staticDir: 'build',
})

@Falldot
Copy link
Owner

Falldot commented Nov 26, 2021

Please send the full text of your error.
What OS do you use? At what point do you get the error?

@nikolamus
Copy link

I get this error when I try running the server with the options above.
I use MacOS 11.6

(node:90358) UnhandledPromiseRejectionWarning: Error: spawn /Users/nikolamusikic/vt/vacationtracker/node_modules/esbuild-dev-server/lib/../../esbuild-dev-server-darwin-x64/devserver EACCES
    at Process.ChildProcess._handle.onexit (internal/child_process.js:269:19)
    at onErrorNT (internal/child_process.js:467:16)
    at processTicksAndRejections (internal/process/task_queues.js:82:21)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:90358) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:90358) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

@bundyo
Copy link

bundyo commented Nov 30, 2021

This happens, because the server binary is not set as executable. Same happens in Linux. Manually making it executable works.

Looking at the makefile and the paths in it, you probably build on Unix-type OS or WSL, so you probably just need a chmod here and there in the makefile.

@cyberwombat
Copy link

Indeed - running chmod u+x node_modules/esbuild-dev-server-darwin-x64/devserver as a patch till fixed

@Falldot Falldot added the bug Something isn't working label Feb 10, 2022
@Falldot Falldot unpinned this issue Feb 10, 2022
@alexandrubagu
Copy link

For Ubuntu you can run
chmod u+x node_modules/esbuild-dev-server-linux-x64/devserver

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants