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

No loader is configured for ".node" files #303

Closed
NuroDev opened this issue May 15, 2021 · 12 comments
Closed

No loader is configured for ".node" files #303

NuroDev opened this issue May 15, 2021 · 12 comments
Labels

Comments

@NuroDev
Copy link

NuroDev commented May 15, 2021

I'm currently working on a project that is using tsup to bundle the backend express server for a vite project.

However, when attempting to call createViteServer I get 2 errors. The first being about not being able to resolve acorn (Adding --external acorn fixed that). However the other error I am not so sure about as such a simple fix for.

Unless I am missing something it seems like .node modules would need to be added to tsup in order to fix this/work around it?

> ../../node_modules/fsevents/fsevents.js:13:23: error: No loader is configured for ".node" files: ../../node_modules/fsevents/fsevents.node
    13 │ const Native = require("./fsevents.node");~~~~~~~~~~~~~~~~~
@falstack
Copy link

@NuroDev i have same issue, you resolve it?

@egoist
Copy link
Owner

egoist commented Jun 29, 2021

For now just externalize any module that imports .node files. (this means moving such packges over to "dependencies" in package.json or using the --external flag explictly)

@egoist egoist closed this as completed in 8cadbb1 Nov 25, 2021
@github-actions
Copy link

🎉 This issue has been resolved in version 5.10.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@alexmarqs
Copy link

Hi @egoist I'm having a similar issue,
`✘ [ERROR] No loader is configured for ".node" files: node_modules/fsevents/fsevents.node

node_modules/fsevents/fsevents.js:13:23:
  13 │ const Native = require("./fsevents.node");
     ╵                        ~~~~~~~~~~~~~~~~~

Error: Build failed with 1 error:
node_modules/fsevents/fsevents.js:13:23: ERROR: No loader is configured for ".node" files: node_modules/fsevents/fsevents.node`,

Tried with multiple versions.

Do you know how can I solve this?

Thanks!

@zvictor
Copy link
Contributor

zvictor commented Jun 11, 2022

@alexmarqs I am facing the same issue. Curious thing is that the simple presence of a config file makes this error appear.

Works:

$ ./node_modules/.bin/tsup src/index.ts --no-config

CLI Building entry: src/index.ts
CLI Using tsconfig: tsconfig.json
CLI tsup v6.1.2
CLI Target: node14
CJS Build start
CJS ⚡️ Build success in 17ms
CJS dist/index.js 1.67 KB

Fails:

$ ./node_modules/.bin/tsup src/index.ts

✘ [ERROR] No loader is configured for ".node" files: ../../node_modules/.pnpm/fsevents@2.3.2/node_modules/fsevents/fsevents.node

    ../../node_modules/.pnpm/fsevents@2.3.2/node_modules/fsevents/fsevents.js:13:23:
      13 │ const Native = require("./fsevents.node");
         ╵                        ~~~~~~~~~~~~~~~~~

In my case, the problem is being caused by tsconfig.json interfering on how tsup parses and handles tsup.config.ts.

{
  "compilerOptions": {
    "baseUrl": "./",
    "paths": {
      "*": ["src/*", "node_modules/*"]
    }
  }
}

Commenting out compilerOptions.paths in the tsconfig.json was enough to make this error go away 🙂

@alexmarqs
Copy link

Hi @zvictor thanks for your feedback as well! In my case I was able to workaround this by just using the tsup property inside package.json for the configuration as an alternative to the config file.

Cheers!

@zvictor
Copy link
Contributor

zvictor commented Jun 11, 2022

Yes, that should work. In fact, any configuration file other than the TS one should work as well.

Would you mind sharing your tsconfig with us?

@alexmarqs
Copy link

@zvictor example -> https://gist.github.com/alexmarqs/009cff7fcceb1b9012c61758298f10f9 + tsup property in package.json (as mentioned above). Hope this helps.

@zvictor
Copy link
Contributor

zvictor commented Jun 12, 2022

Thanks @alexmarqs !
As I can see in your code, you also have a "*" rule defined in compilerOptions.paths.

@egoist should we do any change in tsup to accommodate that or we better keep it like that?

@marcellopato
Copy link

Kinda having the same error but on a Laravel 9 app:

 VITE v4.0.4  ready in 3886 ms

  ➜  Local:   http://localhost:5173/
  ➜  Network: use --host to expose
  ➜  press h to show help

  LARAVEL v9.48.0  plugin v0.7.3

  ➜  APP_URL: http://wb9.test
✘ [ERROR] No loader is configured for ".node" files: node_modules/fsevents/fsevents.node

    node_modules/fsevents/fsevents.js:13:23:
      13 │ const Native = require("./fsevents.node");
         ╵                        ~~~~~~~~~~~~~~~~~

/Users/marcellopato/Documents/Sites/wb9/node_modules/esbuild/lib/main.js:1604
  let error = new Error(`${text}${summary}`);
              ^

Error: Build failed with 1 error:
node_modules/fsevents/fsevents.js:13:23: ERROR: No loader is configured for ".node" files: node_modules/fsevents/fsevents.node
    at failureErrorWithLog (/Users/marcellopato/Documents/Sites/wb9/node_modules/esbuild/lib/main.js:1604:15)
    at /Users/marcellopato/Documents/Sites/wb9/node_modules/esbuild/lib/main.js:1056:28
    at runOnEndCallbacks (/Users/marcellopato/Documents/Sites/wb9/node_modules/esbuild/lib/main.js:1476:61)
    at buildResponseToResult (/Users/marcellopato/Documents/Sites/wb9/node_modules/esbuild/lib/main.js:1054:7)
    at /Users/marcellopato/Documents/Sites/wb9/node_modules/esbuild/lib/main.js:1166:14
    at responseCallbacks.<computed> (/Users/marcellopato/Documents/Sites/wb9/node_modules/esbuild/lib/main.js:701:9)
    at handleIncomingPacket (/Users/marcellopato/Documents/Sites/wb9/node_modules/esbuild/lib/main.js:756:9)
    at Socket.readFromStdout (/Users/marcellopato/Documents/Sites/wb9/node_modules/esbuild/lib/main.js:677:7)
    at Socket.emit (node:events:527:28)
    at addChunk (node:internal/streams/readable:324:12) {
  errors: [
    {
      detail: undefined,
      id: '',
      location: {
        column: 23,
        file: 'node_modules/fsevents/fsevents.js',
        length: 17,
        line: 13,
        lineText: 'const Native = require("./fsevents.node");',
        namespace: '',
        suggestion: ''
      },
      notes: [],
      pluginName: '',
      text: 'No loader is configured for ".node" files: node_modules/fsevents/fsevents.node'
    }
  ],
  warnings: []
}

Node.js v17.9.1

Any hints? And no, it is not about egoistat all. I found this issue thought Google.

theurgi added a commit to theurgi/templates that referenced this issue Apr 11, 2023
The compilerOptions.path setting caused tsup to throw "No loader is configured for '.node' files" and fail to build. See: egoist/tsup#303
@MrShortcut
Copy link

Kinda having the same error but on a Laravel 9 app:

 VITE v4.0.4  ready in 3886 ms

  ➜  Local:   http://localhost:5173/
  ➜  Network: use --host to expose
  ➜  press h to show help

  LARAVEL v9.48.0  plugin v0.7.3

  ➜  APP_URL: http://wb9.test
✘ [ERROR] No loader is configured for ".node" files: node_modules/fsevents/fsevents.node

    node_modules/fsevents/fsevents.js:13:23:
      13 │ const Native = require("./fsevents.node");
         ╵                        ~~~~~~~~~~~~~~~~~

/Users/marcellopato/Documents/Sites/wb9/node_modules/esbuild/lib/main.js:1604
  let error = new Error(`${text}${summary}`);
              ^

Error: Build failed with 1 error:
node_modules/fsevents/fsevents.js:13:23: ERROR: No loader is configured for ".node" files: node_modules/fsevents/fsevents.node
    at failureErrorWithLog (/Users/marcellopato/Documents/Sites/wb9/node_modules/esbuild/lib/main.js:1604:15)
    at /Users/marcellopato/Documents/Sites/wb9/node_modules/esbuild/lib/main.js:1056:28
    at runOnEndCallbacks (/Users/marcellopato/Documents/Sites/wb9/node_modules/esbuild/lib/main.js:1476:61)
    at buildResponseToResult (/Users/marcellopato/Documents/Sites/wb9/node_modules/esbuild/lib/main.js:1054:7)
    at /Users/marcellopato/Documents/Sites/wb9/node_modules/esbuild/lib/main.js:1166:14
    at responseCallbacks.<computed> (/Users/marcellopato/Documents/Sites/wb9/node_modules/esbuild/lib/main.js:701:9)
    at handleIncomingPacket (/Users/marcellopato/Documents/Sites/wb9/node_modules/esbuild/lib/main.js:756:9)
    at Socket.readFromStdout (/Users/marcellopato/Documents/Sites/wb9/node_modules/esbuild/lib/main.js:677:7)
    at Socket.emit (node:events:527:28)
    at addChunk (node:internal/streams/readable:324:12) {
  errors: [
    {
      detail: undefined,
      id: '',
      location: {
        column: 23,
        file: 'node_modules/fsevents/fsevents.js',
        length: 17,
        line: 13,
        lineText: 'const Native = require("./fsevents.node");',
        namespace: '',
        suggestion: ''
      },
      notes: [],
      pluginName: '',
      text: 'No loader is configured for ".node" files: node_modules/fsevents/fsevents.node'
    }
  ],
  warnings: []
}

Node.js v17.9.1

Any hints? And no, it is not about egoistat all. I found this issue thought Google.

y have exaclty the same
✘ [ERROR] No loader is configured for ".node" files: node_modules/fsevents/fsevents.node

node_modules/fsevents/fsevents.js:13:23:
  13 │ const Native = require("./fsevents.node");
     ╵                        ~~~~~~~~~~~~~~~~~

C:\Users\CheatModes4\dev\profesional\updated-react-professional-configuration\node_modules\esbuild\lib\main.js:1636
let error = new Error(${text}${summary});
^

Error: Build failed with 1 error:
node_modules/fsevents/fsevents.js:13:23: ERROR: No loader is configured for ".node" files: node_modules/fsevents/fsevents.node
at failureErrorWithLog (C:\Users\CheatModes4\dev\profesional\updated-react-professional-configuration\node_modules\esbuild\lib\main.js:1636:15)
at C:\Users\CheatModes4\dev\profesional\updated-react-professional-configuration\node_modules\esbuild\lib\main.js:1048:25
at runOnEndCallbacks (C:\Users\CheatModes4\dev\profesional\updated-react-professional-configuration\node_modules\esbuild\lib\main.js:1471:45)
at buildResponseToResult (C:\Users\CheatModes4\dev\profesional\updated-react-professional-configuration\node_modules\esbuild\lib\main.js:1046:7)
at C:\Users\CheatModes4\dev\profesional\updated-react-professional-configuration\node_modules\esbuild\lib\main.js:1058:9
at new Promise ()
at requestCallbacks.on-end (C:\Users\CheatModes4\dev\profesional\updated-react-professional-configuration\node_modules\esbuild\lib\main.js:1057:54)
at handleRequest (C:\Users\CheatModes4\dev\profesional\updated-react-professional-configuration\node_modules\esbuild\lib\main.js:723:19)
at handleIncomingPacket (C:\Users\CheatModes4\dev\profesional\updated-react-professional-configuration\node_modules\esbuild\lib\main.js:745:7)
at Socket.readFromStdout (C:\Users\CheatModes4\dev\profesional\updated-react-professional-configuration\node_modules\esbuild\lib\main.js:673:7)
at Socket.emit (node:events:513:28)
at addChunk (node:internal/streams/readable:324:12)
at readableAddChunk (node:internal/streams/readable:297:9)
at Readable.push (node:internal/streams/readable:234:10)
at Pipe.onStreamRead (node:internal/stream_base_commons:190:23) {
errors: [
{
detail: undefined,
id: '',
location: {
column: 23,
file: 'node_modules/fsevents/fsevents.js',
length: 17,
line: 13,
lineText: 'const Native = require("./fsevents.node");',
namespace: '',
suggestion: ''
},
notes: [],
pluginName: '',
text: 'No loader is configured for ".node" files: node_modules/fsevents/fsevents.node'
}
],
warnings: []
}

Node.js v18.10.0

@segersniels
Copy link

Can confirm that it only pops up when using the config file. Specifying the flags directly to the tsup command or in the package.json config doesn't cause any issues.

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

No branches or pull requests

8 participants