Skip to content

npm run build retrieves The argument 'filename' must be a file URL object, file URL string, or absolute path string #283

Closed

Description

@silvestrevivo

Describe the bug

I've created a npm package that in development it works OK but when I run npm run build it retrieves the next error.

[vite-plugin-svelte] The argument 'filename' must be a file URL object, file URL string, or absolute path string. Received '\x00__vite-browser-external?commonjs-proxy'
> The argument 'filename' must be a file URL object, file URL string, or absolute path string. Received '\x00__vite-browser-external?commonjs-proxy'

Reproduction

This is the repo where this is happening.

https://github.com/silvestrevivo/solana-svelte-counter

I think it would be difficult to reproduce since you need to deploy the smart contract to run the project. With the SvelteKit version 251 this bug doesn't occur. As soon as you upgrade SvelteKit, the error happens.

Logs

[vite-plugin-svelte] The argument 'filename' must be a file URL object, file URL string, or absolute path string. Received '\x00__vite-browser-external?commonjs-proxy'
> The argument 'filename' must be a file URL object, file URL string, or absolute path string. Received '\x00__vite-browser-external?commonjs-proxy'
    at new NodeError (node:internal/errors:371:5)
    at createRequire (node:internal/modules/cjs/loader:1210:13)
    at resolveViaPackageJsonSvelte (file:///Users/silvestrevivo/werk/2021/solana/solana-svelte-counter/app/node_modules/@sveltejs/vite-plugin-svelte/dist/index.js:1427:26)
    at Object.resolveId (file:///Users/silvestrevivo/werk/2021/solana/solana-svelte-counter/app/node_modules/@sveltejs/vite-plugin-svelte/dist/index.js:1585:24)
    at /Users/silvestrevivo/werk/2021/solana/solana-svelte-counter/app/node_modules/rollup/dist/shared/rollup.js:22795:37

System Info

.

Severity

annoyance

Activity

  1. added
    bugSomething isn't working
    triageAwaiting triage by a project member
    on Feb 27, 2022
  2. ashwinvasudevan commented on Feb 28, 2022

    @ashwinvasudevan

    try, catch has been removed around resolveViaPackageJsonSvelte fn. Adding try catch seems to solve the error. Downgrade to @sveltejs/[email protected] to solve the issue for now

  3. silvestrevivo commented on Feb 28, 2022

    @silvestrevivo
    Author

    @ashwinvasudevan thanks for the answer. I had to downgrade to @sveltejs/[email protected] because sveltekit over 251 is overwriting to @sveltejs/[email protected]. But you are right, it seems an issue from that version what is causing the error.

    I get this problem with this package I am working on right now https://www.npmjs.com/package/@svelte-on-solana/wallet-adapter-ui that is the Official Wallet adapter for Solana Dapps. This is blocking me right now to make support to Svelte devs who want to develop Web3 based on Solana.

    I hope this can be solved soon. Thanks!!!!

  4. ghost removed
    triageAwaiting triage by a project member
    on Feb 28, 2022
  5. nikkwong commented on Mar 2, 2022

    @nikkwong

    @ashwinvasudevan thanks for the answer. I had to downgrade to @sveltejs/[email protected] because sveltekit over 251 is overwriting to @sveltejs/[email protected]. But you are right, it seems an issue from that version what is causing the error.

    I get this problem with this package I am working on right now https://www.npmjs.com/package/@svelte-on-solana/wallet-adapter-ui that is the Official Wallet adapter for Solana Dapps. This is blocking me right now to make support to Svelte devs who want to develop Web3 based on Solana.

    I hope this can be solved soon. Thanks!!!!

    This just broke the deployment of our app and I can't reason as to why as we're not upgrading the major or minor versions of sveltekit, svelte, or vite. What's going on?

    I've tried downgrading to this version but i'm still getting the issue as it seems to be referencing the next-38 package. Is there a trick to getting it to reference the next.37 from package.json?

  6. bluwy commented on Mar 2, 2022

    @bluwy
    Member

    #286 is released in 1.0.0-next.38 which fixes this. Please upgrade to that version to resolve this issue.

  7. nikkwong commented on Mar 2, 2022

    @nikkwong

    Like so? I am still getting the same issue:
    Screen Shot 2022-03-01 at 7 26 11 PM
    )

  8. bluwy commented on Mar 2, 2022

    @bluwy
    Member

    If the workaround proposed in this issue didn't work for you, then it probably means you're hitting a slightly different issue then. I'd suggest providing repros and logs, or create a new issue with it so we can debug further.

  9. nikkwong commented on Mar 2, 2022

    @nikkwong

    Thanks! It certainly seems to be the same issue, since the logging output is the same as the originally referenced one:

    [vite-plugin-svelte] The argument 'filename' must be a file URL object, file URL string, or absolute path string. Received '\x00__vite-browser-external?commonjs-proxy'
    > The argument 'filename' must be a file URL object, file URL string, or absolute path string. Received '\x00__vite-browser-external?commonjs-proxy'
        at new NodeError (internal/errors.js:322:7)
        at createRequire (internal/modules/cjs/loader.js:1182:13)
        at resolveViaPackageJsonSvelte (file:///node_modules/.pnpm/@[email protected][email protected][email protected]/node_modules/@sveltejs/vite-plugin-svelte/dist/index.js:1427:26)
    
  10. xpluscal commented on Mar 2, 2022

    @xpluscal

    @nikkwong FYI: I am receiving the exact same issue, but I don't have vite-plugin-svelte installed. Maybe an issue with kit?

  11. nikkwong commented on Mar 2, 2022

    @nikkwong

    I was trying to install vite-plugin-svelte to override the version that the package itself uses; but to no avail. We can no longer build our app and can't find a workaround. Can this issue be reopened?

  12. xpluscal commented on Mar 2, 2022

    @xpluscal

    Actually reverting: It is caused by vite-plugin-svelte apparently. the plugin was installed as dep of kit

  13. bluwy commented on Mar 2, 2022

    @bluwy
    Member

    Ugh I'm sorry. Turns out the fix is not released yet 😢

  14. reopened this on Mar 2, 2022
  15. xpluscal commented on Mar 2, 2022

    @xpluscal

    thx @bluwy. Any known workarounds?

    I'm curious how that happens even if no minor / major version bumps of svelte/kit or /vite-plugin-svelte happened?
    Any versions that would not encounter this issue?
    As @nikkwong mentioned it is breaking build processes (for us as well)

  16. bluwy commented on Mar 2, 2022

    @bluwy
    Member

    Might be an upgrade to Vite that causes the issue. But usually it's hard to know where this was caused on this part of the code. I'll check with @dominikg to make a new release soon.

  17. xpluscal commented on Mar 2, 2022

    @xpluscal

    super thank you @bluwy 🙏

  18. ghost closed this as completedin #288on Mar 2, 2022
  19. silvestrevivo commented on Mar 2, 2022

    @silvestrevivo
    Author

    @dominikg @bluwy thank you so much for solving this!!!

  20. Nisthar commented on May 16, 2022

    @Nisthar

    @dominikg @bluwy thank you so much for solving this!!!

    I am getting the same error still

    image

  21. Nisthar commented on May 16, 2022

    @Nisthar

    @Nisthar

    this seems to be a different cause with a similar error message. Please file a new issue and provide a reproduction.

    ok created a new issue here #340

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions