The parameter of the resolve function may be undefined
See original GitHub issueDescribe the bug
The parameter of the resolve function may be undefined
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
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn’t already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it’s a Vue SFC related bug, it should likely be reported to https://github.com/vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (4 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The issue you are facing is you need to provide
entry
tolib
options if you are building a library. There is nolib.entry
in your config, so it is undefined.https://github.com/vitejs/vite/blob/55589db970c9abf0f67538271c9dce40ace9f5ad/packages/vite/src/node/build.ts#L382
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.