镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Cannot find module when sub-package depends on the root package #762

Closed

Description

@charlespierce

Due to our file structure not exactly matching what Node expects (i.e. we don't have node_modules and we have an extra version directory), sub packages within an installed binary can't require anything from the main package. This causes problems in @vue/cli, as running the command vue ui results in @vue/cli-ui (a dependency) trying to require('@vue/cli/lib/util/rcPath') (a module in the root package), which fails because Node can't find the root package.

We should come up with a directory structure that adheres to Node's resolution algorithm or otherwise come up with a way of installing tools so that the root package can be accessed from sub-packages.

Activity

  1. charlespierce commented on Jun 11, 2020

    @charlespierce
    ContributorAuthor

    One thought (which may also simplify a lot of the work around package installs and the interop between them):

    Create a structure like the following:
    tools/packages/{node_version}/

    Then instead of the bespoke logic we use, call npm i -g --prefix=${VOLTA_HOME}/tools/packages/{node_version} to effectively leverage the existing global install behavior from npm.

    Some concerns with this: It silos packages off by the Node version, which is one of the things we explicitly wanted to avoid with Volta. While we can still use the shim behavior to run the tool in any context, it means some of the interoperability would be limited by specific Node version, which seems difficult to explain in docs and confusing for users.

  2. charlespierce commented on Oct 22, 2020

    @charlespierce
    ContributorAuthor

    With Volta 0.9.0, now that we are using the package manager directory layout, this should no longer be an issue as there is a node_modules directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions