cli: ESM dependencies in v2 functions in pnpm repo cause crash in dev

Describe the bug

If a repo uses pnpm and has any ESM dependency used by functions, running ntl dev causes the CLI to crash with the following error:

NestedError: Cannot read from `/Users/matt/Repos/esm-dep-demo/node_modules/.pnpm/filenamify@6.0.0/node_modules/filename-reserved-regex`: EISDIR: illegal operation on a directory, read
    at Module.createReadStream (file:///Users/matt/.nvm/versions/node/v18.18.2/lib/node_modules/netlify-cli/node_modules/cp-file/fs.js:21:9)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at copyFileAsync (file:///Users/matt/.nvm/versions/node/v18.18.2/lib/node_modules/netlify-cli/node_modules/cp-file/index.js:11:21)
    at file:///Users/matt/.nvm/versions/node/v18.18.2/lib/node_modules/netlify-cli/node_modules/p-map/index.js:141:20
Caused By: Error: EISDIR: illegal operation on a directory, read

  System:
    OS: macOS 13.4.1
    CPU: (8) arm64 Apple M1
  Binaries:
    Node: 18.18.2 - ~/.nvm/versions/node/v18.18.2/bin/node
    Yarn: 1.22.19 - /opt/homebrew/bin/yarn
    npm: 9.8.1 - ~/.nvm/versions/node/v18.18.2/bin/npm
  Browsers:
    Chrome: 118.0.5993.117
    Safari: 16.5.1
  npmGlobalPackages:

Steps to reproduce

Configuration

No response

Environment

System: OS: macOS 13.4.1 CPU: (8) arm64 Apple M1 Memory: 79.47 MB / 8.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 18.18.2 - ~/.nvm/versions/node/v18.18.2/bin/node Yarn: 1.22.19 - /opt/homebrew/bin/yarn npm: 9.8.1 - ~/.nvm/versions/node/v18.18.2/bin/npm pnpm: 8.9.0 - ~/Library/pnpm/pnpm npmGlobalPackages: netlify-cli: 16.9.3

About this issue

  • Original URL
  • State: closed
  • Created 8 months ago
  • Comments: 17 (10 by maintainers)

Most upvoted comments

https://github.com/netlify/cli/pull/6385, once merged + released, should resolve this

The error message stems from this line: https://github.com/netlify/zip-it-and-ship-it/blob/9e82c5a761d0a00fe92cb8221f7e48756f46d06e/src/runtimes/node/utils/zip.ts#L158-L160

I’ll see if I can reproduce this bug within zip-it-and-ship-it alone.

Ha, that’s it! Can reproduce now, thank you. I’ll do some digging into what’s causing this next 👍

Hey @jnschrag! I’d like to look into what’s failing for you. You’ve already shared a bunch about the setup, but I can’t spot anything in there that leads to a bug. Could you share a reproduction repository that I can clone and run locally to look at this?

Thanks so much! I really appreciate it. Here is a test repo that demonstrates the issue. I did eventually find a workaround that actually works (using a plugin) so I’ve included that as well.

@stormwarning sorry to hear you’re still experiencing this issue. I’ve reopened it so we can investigate further.

Thanks @eduardoboucas, I just tried the latest version but it’s unable to find the symlink

Error: ENOENT: no such file or directory, symlink '../../node_modules/.pnpm/rss-to-json@2.1.1/node_modules/rss-to-json' -> '/Users/jnelson/Projects/tidaltheory-www/www/.netlify/functions-serve/letterboxd/node_modules/rss-to-json'

  System:
    OS: macOS 13.5.1
    CPU: (10) arm64 Apple M1 Pro
  Binaries:
    Node: 18.18.2 - ~/.nvm/versions/node/v18.18.2/bin/node
    npm: 9.8.1 - ~/.nvm/versions/node/v18.18.2/bin/npm
  Browsers:
    Chrome: 118.0.5993.117
    Safari: 16.6
  npmGlobalPackages:
    netlify-cli: 17.0.1

Maybe because this is in a monorepo setup?

@stormwarning it’s being addressed in https://github.com/netlify/zip-it-and-ship-it/pull/1640. I’ll update this issue once there’s a new CLI release.