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

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:4
  • Comments:18 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
ashwinvasudevancommented, Feb 28, 2022

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

0reactions
Nistharcommented, 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 https://github.com/sveltejs/vite-plugin-svelte/issues/340

Read more comments on GitHub >

github_iconTop Results From Across the Web

typescript - The argument 'filename' must be a file URL object ...
The argument 'filename' must be a file URL object, file URL string, or absolute path string. Received 'http://localhost/eslintrc.cjs'.
Read more >
7 Working with file system paths and file URLs on Node.js
Concatenates the paths and return a fully qualified path. It uses the following algorithm: Start with the current working directory. Resolve path[0] against...
Read more >
TypeError: The argument 'filename' must be a file URL object
TypeError : The argument 'filename' must be a file URL object, file URL string, or absolute path string. Received undefined.
Read more >
URL | Node.js v19.3.0 Documentation
A URL string is a structured string containing multiple meaningful ... Gets the URLSearchParams object representing the query parameters of the URL.
Read more >
lint-staged - npm
Run linters against staged git files and don't let slip into your ... argument string (default: 0) --no-stash disable the backup stash, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found