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

Fails with "Path must be a string" on Node 8 #6

Closed
marionebl opened this issue Nov 19, 2017 · 6 comments
Closed

Fails with "Path must be a string" on Node 8 #6

marionebl opened this issue Nov 19, 2017 · 6 comments

Comments

@marionebl
Copy link

marionebl commented Nov 19, 2017

In certain conditions import-fresh fails with the error message Path must be a string. Received null on Node 8.

importFresh('global-dirs');
 Path must be a string. Received null
  module.exports.moduleId (~/node_modules/import-fresh/index.js:11:36)
  ...

Example build: travis/commitlint#L1738

Digging deeper reveals this is caused by caller-path returning a Callsite that returns null from its getFileName method: caller-path/index.js#L4

This in turn is caused by caller-callsite returning always the very first Callsite it finds by breaking out of the iteration here: caller-callsite/index.js#L13

Removing the break statement fixes the issue for me - I am not familiar with the APIs used here, so I am not very confident this is the appropriate fix though.

Steps to reproduce

n 8.9.1
git clone https://github.com/marionebl/commitlint.git
cd commitlint 
git checkout import-fresh-null-repro
npx lerna bootstrap
cd `@commitlint/core
npx ava src/library/resolve-extends.test.js
marionebl added a commit to conventional-changelog/commitlint that referenced this issue Nov 19, 2017
marionebl added a commit to conventional-changelog/commitlint that referenced this issue Nov 19, 2017
* chore: avoid gpg password prompt

* test(core): add failing test case for global extends resolving

* fix(core): fall back to globally installed config if available #126

* test: use cwd correctly for git config

* test: improve testability of global fallback

* fix(core): ensure resolve-globals is detected as dependency

* fix: use more recent import-fresh

* fix: fall back to require-uncached

Avoid sindresorhus/import-fresh#6 for the time being

* fix: pull in patch releases
@aladdin-add
Copy link

same issue in eslint: eslint/eslint#11066

@aladdin-add
Copy link

friendly ping @sindresorhus

@sindresorhus
Copy link
Owner

Can you try out v3.0.0? It improves the logic for finding the module to clear.

@aladdin-add
Copy link

aladdin-add commented Dec 25, 2018

seems not, I've upgrade to import-fresh@3.0.0, but getting another error: https://ci.appveyor.com/project/nzakas/eslint/builds/21226625

oops it's working, thanks for fixing this!

@aladdin-add
Copy link

@sindresorhus seems the issue could be closed!

@sindresorhus
Copy link
Owner

Great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants