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

Using yarn 2 pnp with package.json scripts cause ENOTDIR #184

Open
Gisleburt opened this issue Jan 6, 2021 · 2 comments
Open

Using yarn 2 pnp with package.json scripts cause ENOTDIR #184

Gisleburt opened this issue Jan 6, 2021 · 2 comments

Comments

@Gisleburt
Copy link

I've added migrate to my package json so that it always passes in the correct store, complier and template options¹

If I try to use it directly, eg:

{
  "scripts": {
    "migrate-create": "migrate create --template-file=\"./migrations-meta/template.ts\" --compiler=\"ts:./migrations-meta/compiler.js\"",
  }
}

When I run it with yarn 2 I get the following error

$ yarn run migrate-create test
internal/child_process.js:407
    throw errnoException(err, 'spawn');
    ^

Error: spawn ENOTDIR
    at ChildProcess.spawn (internal/child_process.js:407:11)
    at spawn (child_process.js:548:9)
    at Command.executeSubCommand (./.yarn/cache/commander-npm-2.20.3-d8dcbaa39b-b73428e97d.zip/node_modules/commander/index.js:562:14)
    at Command.parse (./.yarn/cache/commander-npm-2.20.3-d8dcbaa39b-b73428e97d.zip/node_modules/commander/index.js:488:17)
    at Object.<anonymous> (./.yarn/cache/migrate-npm-1.7.0-d0c8b01ed6-666dcd3e4d.zip/node_modules/migrate/bin/migrate:15:4)
    at Module._compile (internal/modules/cjs/loader.js:1137:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
    at Module.load (internal/modules/cjs/loader.js:985:32)
    at Function.external_module_.Module._load (./.pnp.js:20698:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12) {
  errno: 'ENOTDIR',
  code: 'ENOTDIR',
  syscall: 'spawn'
}

I have a work around by prefixing migrate with npx which then installs and runs a global version of migrate.

We're using yarn 2 with pnp, however other binaries run ok. Did I miss something?

¹ Is there a runtime configuration (rc) file that I missed or isn't not documented so that I don't have to do this?

@wesleytodd
Copy link
Collaborator

I am fairly confident that this package will not work with yarn pnp. They do some extensive overriding of node internals and this package uses some dynamic imports which IIRC will break. I don't use yarn and especially not with pnp, but if you can find a fix which is backward compatible I am happy to take a PR.

@polad
Copy link
Contributor

polad commented Feb 3, 2023

@Gisleburt I experienced a similar issue after switching to Yarn berry v3.3.1 with "Zero Installs" and resolved it by unplugging the migrate package like so:

> yarn unplug migrate

This will unpack the cached zip archive of the migrate package under the .yarn/unplugged/ folder. This will also reference the migrate package in the package.json under dependenciesMeta so that yarn treats this package as unplugged during the future installs. This means the package will be unpacked for everyone doing yarn install. The good news is the package archive will still be cached under .yarn/cache (i.e. checked into git repo) so it won't download it.

Here is more info from yarn docs: https://yarnpkg.com/cli/unplug

Hope it helps anyone using this package.

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

3 participants