Git Product home page Git Product logo

Comments (4)

aldeed avatar aldeed commented on May 14, 2024

@ticean Any thoughts about how we can best have that .yarnrc config apply within containers but not outside? I think this was initially fine because local node_modules was linked into the container, but now that we use a separate volume for node_modules, there are some dev deps that need to be installed outside of docker for IDEs to pick them up (primarily eslint)

from generator-reaction.

ticean avatar ticean commented on May 14, 2024

The .yarnrc config prevents yarn from working outside the Docker container. IMO a good thing.

When one runs npm|npx|yarn install from the development host machine then the node_modules dependency directory is created on the host. Then it is always mounted into the Docker container as long as it exists. There's a few problems with that:

  • Runtime compatibility issues (C-bindings built on Mac that fail to run in Linux)
  • "Works on my machine" because manually installed development dependencies out of sync with what's actually in the committed code. Container doesn't match image.

Both tricky problems to debug. I think it's best to prevent it completely and embrace the remote Docker environment.


It seems the hurdle is that @machikoyasuda wants her IDE to use the project's runtime for linting, but that runtime is remote. Here are some options:

a. Global Linting Dependencies

Don't depend on the project runtime. Install the dependencies in the global development environment.

b. Use the Containerized Environment

a1) Modify the command script that the IDE uses to run the lint in a Dockerized command. That should be fairly easy to do.

a2) Or, treat this similarly to remote debugging. Is there a plugin or technique that will attach to the remote environment? That would probably require some assumption on IDE choice as it may introduce project files to support it.

c. Load Dependencies from Outside the Project Directory

Alternatively, the same trick that we use inside the container could work in the development environment.

Node searches up the directory tree to find a node_modules, so you could install dependencies in a parent directory on the development machine.

cp package.json ../
cd ..
npm install
# cd back to project and do work...

from generator-reaction.

aldeed avatar aldeed commented on May 14, 2024

@ticean Are you sure host node_modules is mounted into the container? Since container node_modules is linked with a volume, it doesn't seem like anything in host node_modules has any effect in the container. e.g. If I npm install something into host node_modules, app running in the container will still complain that it isn't there.

from generator-reaction.

ticean avatar ticean commented on May 14, 2024

Oh, right @aldeed. I forgot about that change with the mounted volume. Thanks. The hard paths in the yarn.rc directives are the only things that prevent it from working on the host. I haven't tested but possible that interpolated vars like $HOME or ~ might work. You could always leave those out completely. I do remember seeing some significant performance boosts with the caching but not sure how that was affected with the changes to the mount.

from generator-reaction.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.