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

TypeError: Expected cwd to be of type string but received type undefined #265

Closed
bartdelange opened this issue Jan 12, 2019 · 11 comments
Closed

Comments

@bartdelange
Copy link

bartdelange commented Jan 12, 2019

When executing any cli command it fails and gives the error below, this however does work if I use yarn. (has also been referenced here: #264)

Example command (the style.css is just an empty file):

"start": "postcss --use autoprefixer -o ./style.css ./style.css"

Stacktrace:

TypeError: Expected `cwd` to be of type `string` but received type `undefined`
    at module.exports (/path/to/project/node_modules/dir-glob/index.js:44:25)
    at globDirs (/path/to/project/node_modules/globby/index.js:58:9)
    at getPattern (/path/to/project/node_modules/globby/index.js:61:64)
    at Promise.all.globTasks.map.task (/path/to/project/node_modules/globby/index.js:72:69)
    at Array.map (<anonymous>)
    at module.exports (/path/to/project/node_modules/globby/index.js:72:41)
    at Promise.resolve.then (/path/to/project/node_modules/postcss-cli/index.js:58:14)
    at process._tickCallback (internal/process/next_tick.js:68:7)
    at Function.Module.runMain (internal/modules/cjs/loader.js:744:11)
    at findNodeScript.then.existing (/[user]/.nvm/versions/node/v10.12.0/lib/node_modules/npm/node_modules/libnpx/index.js:268:14)
@jelgersma
Copy link

I have the exact same error.

NPM Version: 6.4.1
Node Version: 10.15.0

@RyanZim
Copy link
Collaborator

RyanZim commented Jan 12, 2019

Have you tried a fresh installation?

@bartdelange
Copy link
Author

I have, weirdly enough just running the example in postcss/autoprefixer works as well, so it must be a version issue, but npm ls lists the same versions

npm install postcss-cli autoprefixer
npx postcss *.css --use autoprefixer -d build/

@RyanZim
Copy link
Collaborator

RyanZim commented Jan 12, 2019

Yeah, there was a sub-dependency way down in the dependency tree that had a bug and broke semver. Your postcss-cli versions will be the same; that's expected, but what's important is that the sub-dependency is updated.

@bartdelange
Copy link
Author

bartdelange commented Jan 12, 2019

So manually forcing the sub dep version should fix it (and which)?

@bartdelange
Copy link
Author

It does indeed, after manually installing the globby version (and then doing a fresh install leaving globby out of the package.json) it runs. I think is seems to be a cache issue or something even though the cache should be self healing

@kevva
Copy link

kevva commented Jan 14, 2019

Yes, this was fixed in sindresorhus/globby#99. Reinstalling postcss-cli should fix it.

@mattfelten
Copy link

npm update globby --depth 5 fixed it for me. NPM was keeping the version locked to a lower version because deduping or something.

@targos
Copy link
Contributor

targos commented Feb 22, 2019

The best would be to update globby to version ^9.0.0 in this package.

@RyanZim
Copy link
Collaborator

RyanZim commented Feb 22, 2019

@targos PR welcome

@targos
Copy link
Contributor

targos commented Feb 22, 2019

#270

RyanZim pushed a commit that referenced this issue Feb 22, 2019
alemesa added a commit to alemesa/imagemin that referenced this issue Mar 1, 2019
This should fix imagemin#311 like @DonghyukJacobJang

This is a bug with globby which has happened across many repos:

References:
Stylelint => stylelint/stylelint#3885
PostCSS => postcss/postcss-cli#265
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants