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

fix(dlx): set saveProd to true for getting pkgName from dependencies #7540

Merged
merged 3 commits into from
Jan 19, 2024

Conversation

await-ovo
Copy link
Member

fix #7424

@zkochan
Copy link
Member

zkochan commented Jan 19, 2024

Thanks for fixing this. I don't fully understand what was the problem though.

@await-ovo
Copy link
Member Author

await-ovo commented Jan 19, 2024

Thanks for fixing this. I don't fully understand what was the problem though.

Thanks for your review ~

If we run npm_config_save_dev=true pnpm dlx create-react-app ./my-app, and we can see the error thrown in the issue above:

$ npm_config_save_dev=true pnpm dlx create-react-app ./my-app
 WARN  1 deprecated subdependencies found: tar@2.2.2
Packages: +67
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Progress: resolved 67, reused 67, downloaded 0, added 67, done
 ERR_INVALID_ARG_TYPE  The "path" argument must be of type string. Received undefined

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

The reason for the error is that create-react-app is installed to the devDependencies in temp dlxDir, which results in an undefined pkgName.

Although almost no one uses pnpm dlx like this, in the original issue, when pnpm dlx was existing in postsinstall script:

// package.json
{
  "scripts": {
    "postinstall": "pnpm dlx create-react-app ./my-app"
  }
}

Running pnpm add some-package -D in this project will get the same error. The reason for this is that when executing the postinstall life hook, we will set npm-config-save-dev environment variable from cliOptions.

I don't know if there's another better way to fix this, I think setting saveProd to true when adding package in dlx should fix this problem.

@zkochan zkochan merged commit d172d73 into pnpm:main Jan 19, 2024
8 checks passed
zkochan added a commit that referenced this pull request Jan 19, 2024
…7540)

close #7424

---------

Co-authored-by: Zoltan Kochan <z@kochan.io>
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

Successfully merging this pull request may close these issues.

Installing a dev dependency when filtering fails when postinstall script runs pnpm dlx
2 participants