Skip to content

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

@uns3t

Description

@uns3t

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
        }
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions