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

[Bug] yarn 3.2.0 throws error when building via rollup + node 17 + typescript + PnP #4151

Closed
1 task
wdfinch opened this issue Feb 23, 2022 · 7 comments
Closed
1 task
Labels
bug Something isn't working stale Issues that didn't get attention

Comments

@wdfinch
Copy link

wdfinch commented Feb 23, 2022

Self-service

  • I'd be willing to implement a fix

Describe the bug

It seems that if we try to build a project via rollup with node 17, yarn 3.2.0, and typescript, then we get the following error

/home/wfinch/.local/share/nvm/v17.6.0/bin/node /home/wfinch/.local/share/nvm/v17.6.0/lib/node_modules/yarn/bin/yarn.js run build

src/index.ts → build/index.js, build/index.esm.js...
[!] TypeError: The "path" argument must be of type string. Received an instance of Buffer
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received an instance of Buffer
    at new NodeError (node:internal/errors:372:5)
    at validateString (node:internal/validators:120:11)
    at Object.isAbsolute (node:path:1157:5)
    at VirtualFS.mapToBase (/home/wfinch/test/rollup-issues/.pnp.cjs:4327:24)
    at VirtualFS.rmdirSync (/home/wfinch/test/rollup-issues/.pnp.cjs:4176:39)
    at PosixFS.rmdirSync (/home/wfinch/test/rollup-issues/.pnp.cjs:4176:24)
    at URLFS.rmdirSync (/home/wfinch/test/rollup-issues/.pnp.cjs:4176:24)
    at _rmdirSync (node:internal/fs/rimraf:260:21)
    at rimrafSync (node:internal/fs/rimraf:193:7)
    at node:internal/fs/rimraf:253:9


Process finished with exit code 1

The error is around this code in .pnp.cjs

mapToBase(p) {
   if (p === ``)
     return p;
   if (this.pathUtils.isAbsolute(p))
     return VirtualFS.resolveVirtual(p);
   const resolvedRoot = VirtualFS.resolveVirtual(this.baseFs.resolve(PortablePath.dot));
   const resolvedP = VirtualFS.resolveVirtual(this.baseFs.resolve(p));
   return ppath.relative(resolvedRoot, resolvedP) || PortablePath.dot;
 }


To reproduce

  1. Open the attached project
  2. Set the yarn version to 3.2.0
  3. Run yarn install
  4. Run yarn build
  5. Notice the error

rollup-issues.zip

Environment

OS: Ubuntu 20.04 LTS
CPU: Intel Core i9 10th gen
Node version: 17.6.0
Yarn version: 3.2.0
NPM version: 8.3.2

Additional context

This seems related to #1818 however I'm not trying to import and use the FS system. Instead .pnp.cjs is crashing. Perhaps some conversion of buffer to a string can be done as a temp workaround.

@wdfinch wdfinch added the bug Something isn't working label Feb 23, 2022
@wdfinch wdfinch changed the title yarn 3.2.0 throws error when building via rollup + node 17 + typescript + PnP [Bug] yarn 3.2.0 throws error when building via rollup + node 17 + typescript + PnP Feb 23, 2022
@davidcalhoun
Copy link

Got a very similar error (when running Next.js in dev mode) on 3.2.0:

node:internal/validators:119
    throw new ERR_INVALID_ARG_TYPE(name, 'string', value);
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The "id" argument must be of type string. Received null
    at new NodeError (node:internal/errors:371:5)
    at validateString (node:internal/validators:119:11)
    at Module.require (node:internal/modules/cjs/loader:998:3)
    at require (node:internal/modules/cjs/helpers:102:18)
    at execMethod (/Users/dcalhoun/dev/[REDACTED]/.yarn/__virtual__/next-virtual-c99c3f6b7a/0/cache/next-npm-12.1.0-7f99f50e0f-36dbafd5e6.zip/node_modules/next/dist/compiled/jest-worker/processChild.js:1:2364)
    at process.messageListener (/Users/dcalhoun/dev/[REDACTED]/.yarn/__virtual__/next-virtual-c99c3f6b7a/0/cache/next-npm-12.1.0-7f99f50e0f-36dbafd5e6.zip/node_modules/next/dist/compiled/jest-worker/processChild.js:1:1282)
    at process.emit (node:events:390:28)
    at emit (node:internal/child_process:917:12)
    at processTicksAndRejections (node:internal/process/task_queues:84:21) {
  code: 'ERR_INVALID_ARG_TYPE'
}

@eltonio450
Copy link

eltonio450 commented Mar 23, 2022

same here with jest-worker. We also observed the same issue with our TerserPlugin

TypeError [ERR_INVALID_ARG_TYPE]: The "id" argument must be of type string. Received null
    at new NodeError (internal/errors.js:322:7)
    at validateString (internal/validators.js:124:11)
    at Module.require (internal/modules/cjs/loader.js:967:3)
    at require (internal/modules/cjs/helpers.js:93:18)
    at execMethod (/Users/asauvage/themis/.yarn/cache/jest-worker-npm-25.5.0-32bd2bf072-773ad5c680.zip/node_modules/jest-worker/build/workers/processChild.js:113:16)
    at process.messageListener (/Users/asauvage/themis/.yarn/cache/jest-worker-npm-25.5.0-32bd2bf072-773ad5c680.zip/node_modules/jest-worker/build/workers/processChild.js:46:7)
    at process.emit (events.js:400:28)
    at emit (internal/child_process.js:912:12)
    at processTicksAndRejections (internal/process/task_queues.js:83:21) {
  code: 'ERR_INVALID_ARG_TYPE'
}

seems to be related to a parallelization issue ?

@yarnbot

This comment was marked as outdated.

@yarnbot yarnbot added the stale Issues that didn't get attention label Apr 22, 2022
@tobilen
Copy link

tobilen commented Apr 22, 2022

definitely not stale. i am encountering the same problem as described by @eltonio450. it is preventing me from upgrading yarn.

@MrChrisRodriguez
Copy link

Node 14.19... anyone figured out a workaround?

    at new NodeError (internal/errors.js:322:7)
    at validateString (internal/validators.js:124:11)
    at Module.require (internal/modules/cjs/loader.js:967:3)
    at require (internal/modules/cjs/helpers.js:101:18)
    at execMethod (<path>/.cache/yarn/cache/jest-worker-npm-26.6.2-46cbcd449f-f9afa3b88e.zip/node_modules/jest-worker/build/workers/processChild.js:113:16)
    at process.messageListener (<path>/.cache/yarn/cache/jest-worker-npm-26.6.2-46cbcd449f-f9afa3b88e.zip/node_modules/jest-worker/build/workers/processChild.js:46:7)
    at process.emit (events.js:400:28)
    at emit (internal/child_process.js:912:12)
    at processTicksAndRejections (internal/process/task_queues.js:83:21) {
  code: 'ERR_INVALID_ARG_TYPE'
}
internal/validators.js:124
    throw new ERR_INVALID_ARG_TYPE(name, 'string', value);```

@merceyz
Copy link
Member

merceyz commented May 9, 2022

@davidcalhoun @eltonio450 @tobilen @MrChrisRodriguez Those errors look like #4157, try updating Node.js.

@merceyz
Copy link
Member

merceyz commented May 9, 2022

Duplicate of #1818

@merceyz merceyz marked this as a duplicate of #1818 May 9, 2022
@merceyz merceyz closed this as completed May 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working stale Issues that didn't get attention
Projects
None yet
Development

No branches or pull requests

7 participants