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

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

Closed
silvestrevivo opened this issue Feb 27, 2022 · 18 comments · Fixed by #288
Labels
bug Something isn't working

Comments

@silvestrevivo
Copy link

silvestrevivo commented Feb 27, 2022

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

@silvestrevivo silvestrevivo added bug Something isn't working triage Awaiting triage by a project member labels Feb 27, 2022
@ashwinvasudevan
Copy link

try, catch has been removed around resolveViaPackageJsonSvelte fn. Adding try catch seems to solve the error. Downgrade to @sveltejs/vite-plugin-svelte@1.0.0-next.37 to solve the issue for now

@silvestrevivo
Copy link
Author

@ashwinvasudevan thanks for the answer. I had to downgrade to @sveltejs/vite-plugin-svelte@1.0.0-next.36 because sveltekit over 251 is overwriting to @sveltejs/vite-plugin-svelte@1.0.0-next.38. 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!!!!

@nikkwong
Copy link

nikkwong commented Mar 2, 2022

@ashwinvasudevan thanks for the answer. I had to downgrade to @sveltejs/vite-plugin-svelte@1.0.0-next.36 because sveltekit over 251 is overwriting to @sveltejs/vite-plugin-svelte@1.0.0-next.38. 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?

@bluwy
Copy link
Member

bluwy commented Mar 2, 2022

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

@bluwy bluwy closed this as completed Mar 2, 2022
@nikkwong
Copy link

nikkwong commented Mar 2, 2022

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

@bluwy
Copy link
Member

bluwy commented Mar 2, 2022

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.

@nikkwong
Copy link

nikkwong commented Mar 2, 2022

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/@sveltejs+vite-plugin-svelte@1.0.0-next.38_svelte@3.30.1+vite@2.8.4/node_modules/@sveltejs/vite-plugin-svelte/dist/index.js:1427:26)

@xpluscal
Copy link

xpluscal commented Mar 2, 2022

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

@nikkwong
Copy link

nikkwong commented Mar 2, 2022

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?

@xpluscal
Copy link

xpluscal commented Mar 2, 2022

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

@bluwy
Copy link
Member

bluwy commented Mar 2, 2022

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

@bluwy bluwy reopened this Mar 2, 2022
@xpluscal
Copy link

xpluscal commented Mar 2, 2022

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)

@bluwy
Copy link
Member

bluwy commented Mar 2, 2022

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.

@xpluscal
Copy link

xpluscal commented Mar 2, 2022

super thank you @bluwy 🙏

@silvestrevivo
Copy link
Author

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

@Nisthar
Copy link

Nisthar commented May 16, 2022

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

I am getting the same error still

image

@dominikg
Copy link
Member

@Nisthar

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

@Nisthar
Copy link

Nisthar commented May 16, 2022

@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
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants