Skip to content

Can't install module with Yarn 3.x (berry) #139

@FezVrasta

Description

@FezVrasta

We have #44 but it's about Yarn 1 I think.

yarn add node results in an error with the following logs:

# This file contains the result of Yarn building a package (node@npm:14.18.1)
# Script name: preinstall

internal/modules/cjs/loader.js:818
  throw err;
  ^

Error: Cannot find module '/Users/federicozivolo/Projects/app/node_modules/node/bin/node'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)
    at Function.Module._load (internal/modules/cjs/loader.js:667:27)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
    at internal/main/run_main_module.js:17:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

I think the problem is that Yarn 3.x runs preinstall hooks as part of the postinstall cycle.

https://yarnpkg.com/advanced/lifecycle-scripts#:~:text=For%20backwards%20compatibility%2C-,preinstall,-and%20install%20are

I'm on macOS 11.6 running Node.js 14.18.1

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions