Giter Site home page Giter Site logo

Comments (6)

FagnerMartinsBrack avatar FagnerMartinsBrack commented on July 29, 2024 2

I have to share an interesting bug that caused an outage and took me a long time to figure out and is directly related to this issue:

https://medium.com/@fagnerbrack/the-story-of-a-stupid-bug-that-is-impossible-to-reproduce-6863ac526172

Basically:

  1. NPM install on local files creates a symlink.
  2. Zipping removes the symlink.
  3. This can cause a bug with tools like app-root-path that uses _dirname which can only happen in prod and is impossible to reproduce locally.

Exactly like what @jorgechen said.

from node-app-root-path.

stoicskyline avatar stoicskyline commented on July 29, 2024

The cause is using __dirname to resolve the root path.

If a module is linked while being used locally in an app, the __dirname in app-root-path may not overlap with the app's path.

It makes using npm link or yarn link quite a hassle. Is there an easy way to fix this, or perhaps app-root-path is simply not intended to be used in a NPM module?

from node-app-root-path.

harryhorton avatar harryhorton commented on July 29, 2024

Ran into this issue in an npm module I was developing. It worked great when actually npm/yarn installed, but not when linked. I ended up just creating a workaround option in my package for project root. However, it'd be great if there was a fallback if linked to somehow get the running project's root.

from node-app-root-path.

MetaMmodern avatar MetaMmodern commented on July 29, 2024

same issue here( Does not work when creating custom package for npm, it starts referring to the package project directory.

from node-app-root-path.

ByScripts avatar ByScripts commented on July 29, 2024

Same problem with pnpm workspaces.

Temporarily, I solved the issue by defining a APP_ROOT_PATH environment var.

"scripts": {
  "dev": "APP_ROOT_PATH=`pwd` my-dev-command"
}

from node-app-root-path.

Related Issues (20)

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.