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

Uncaught error (sync nor async) if main field is not a string #178

Closed
unlight opened this issue Dec 13, 2018 · 5 comments
Closed

Uncaught error (sync nor async) if main field is not a string #178

unlight opened this issue Dec 13, 2018 · 5 comments

Comments

@unlight
Copy link

unlight commented Dec 13, 2018

How to repeat:

git clone https://gist.github.com/14c93c133d9657411e95959e22e32570.git main-is-not-a-string
cd main-is-not-a-string
npm i
node resolve-material-design-iconic-font.js
const resolve = require('resolve');

try {
	resolve('material-design-iconic-font', (err) => {
		console.log('async err', err);
	});	
} catch (err) {
	console.log('sync err', err);
} 

Actual:

path.js:39
    throw new ERR_INVALID_ARG_TYPE('path', 'string', path);
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type object
    at assertPath (path.js:39:11)
    at Object.resolve (path.js:168:7)
    at \Dev\browserify-resolve-zavoloklom-material-design-iconic-font-issue-111\node_modules\resolve\lib\async.js:164:37
    at FSReqWrap.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:53:3)

Expected:
Error should be caught in callback or in catch

resolve: 1.8.1
node v10.8.0

Related issues:
unlight/sublime-import-helper#61
zavoloklom/material-design-iconic-font#111

@unlight
Copy link
Author

unlight commented Dec 13, 2018

main for this package is:

  "main": [
    "./dist/css/*",
    "./dist/fonts/*"
  ],

@ljharb
Copy link
Member

ljharb commented Dec 13, 2018

@unlight either way, that package is broken; main can only be a string. I’d file a bug on that package.

@unlight
Copy link
Author

unlight commented Dec 13, 2018

The question is how can I detect that package is broken.

@ljharb
Copy link
Member

ljharb commented Dec 13, 2018

For sure, I definitely think this is a bug :-)

@ljharb
Copy link
Member

ljharb commented Dec 13, 2018

Thanks for the perfect repro - a fix will be merged shortly, and included in the next release.

@ljharb ljharb closed this as completed in 87e954a Dec 13, 2018
ljharb added a commit to ljharb/resolve that referenced this issue Dec 17, 2018
ljharb added a commit to ljharb/resolve that referenced this issue Dec 17, 2018
ljharb added a commit that referenced this issue Dec 17, 2018
ljharb added a commit that referenced this issue Dec 17, 2018
 - [New] `async`/`sync`/`node-modules-paths`: Adds support for “paths” being a function (#172, #173)
 - [New] Implements a "normalize-options" pseudo-hook (#174)
 - [Fix] `sync`/`async`: fix `preserveSymlinks` option (#177)
 - [Fix] `sync`/`async`: when package.json `main` is not a string, throw an error (#178)
 - [Deps] update `path-parse`
 - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `object-keys`, `safe-publish-latest`, `tape`
 - [Tests] up to `node` `v11.4`, `v10.14`, `v8.14`, `v6.15`
 - [Tests] better failure messages
ljharb added a commit that referenced this issue Jan 17, 2019
ljharb added a commit that referenced this issue Jan 21, 2019
 - [New] `core`: add `worker_threads` in v11.7+
 - [Fix] `sync`/`async`: when package.json `main` is not a string, throw an error (#178)
 - [Fix] TypeError: Path must be a string. Received undefined (#181)
 - [Tests] up to `v11.6`, `v10.15`, `v8.15`, `v6.16`
 - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `tape`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants