question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

The parameter of the resolve function may be undefined

See original GitHub issue

Describe the bug

The parameter of the resolve function may be undefined

https://github.com/vitejs/vite/blob/e385346c53b3bb54f2e1abcb7348e33d7e075fd4/packages/vite/src/node/build.ts#L379-L381

and this will result in an unintelligible error being thrown

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined

If the parameter is not required,maybe it’s better to set the default parameter to '' ? ;

 const resolve = (p: string = '') => path.resolve(config.root, p)

If the parameter is required,Better to print a friendlier tip?

Reproduction

https://github.com/ckvv/vite-demo

System Info

System:
    OS: macOS 10.15.4
    CPU: (8) x64 Intel(R) Core(TM) i5-8257U CPU @ 1.40GHz
    Memory: 24.04 MB / 8.00 GB
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 16.13.0 - ~/.nvm/versions/node/v16.13.0/bin/node
    Yarn: 1.22.17 - ~/.nvm/versions/node/v16.13.0/bin/yarn
    npm: 8.4.1 - ~/.nvm/versions/node/v16.13.0/bin/npm
  Browsers:
    Chrome: 98.0.4758.80
    Edge: 98.0.1108.51
    Firefox: 94.0.2
    Safari: 13.1

Used Package Manager

pnpm

Logs

No response

Validations

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ydcjeffcommented, Feb 18, 2022

The issue you are facing is you need to provide entry to lib options if you are building a library. There is no lib.entry in your config, so it is undefined.

https://github.com/vitejs/vite/blob/55589db970c9abf0f67538271c9dce40ace9f5ad/packages/vite/src/node/build.ts#L382

0reactions
patak-devcommented, May 17, 2022

This only worked in 2.7 because we wrongly resolved input paths in that minor, that @6680 corrected (reverting to the way it worked in 2.6). So it isn’t a breaking change per se. entry is required, even if you don’t use Typescript, an IDE could warn about this. I agree with @bluwy about not adding a runtime guard here.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Promise.resolve returns Undefined - javascript
So it's never executing Promise.resolve(messagesId) . ... the smembersAsync() function returns a promise, that you can simply return:.
Read more >
How to Fix “Promise resolver undefined is not a function” in ...
The argument is a function providing two arguments: a resolve and a reject function to handle successful and failing promises. The example code ......
Read more >
Promise.resolve() - JavaScript - MDN Web Docs
The Promise.resolve() method "resolves" a given value to a Promise. ... can be called with the resolve and reject callbacks as parameters.
Read more >
Documentation - TypeScript 2.0
A property access or a function call produces a compile-time error if the object or function is of a type that includes null...
Read more >
Resolve Error: Undefined Function or Variable - MATLAB & ...
You may encounter the following error message, or something similar, while working with functions or variables in MATLAB ® : Undefined function or...
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