node-app-root-path icon indicating copy to clipboard operation
node-app-root-path copied to clipboard

fix: #28

Open seognil opened this issue 6 years ago • 2 comments

I meet the bug for my tool la-starter-cli

It seems the same as #28

the bug

In my case,
app-root-path parse my tool's appRoot as /usr/local/lib/ on Mac

So I got /usr/local/lib/package.json not found in my code

It should be /usr/local/lib/node_modules/@seognil-lab/la-starter-cli/ instead

(install and run my tool lcli -v) (the bug should appear after reopen my code line 7 & 8 and comment line 10)

the fix

I trace the code, it happens while there are multi node_modules in the path string

e.g. /usr/local/lib/node_modules/@seognil-lab/la-starter-cli/node_modules/app-root-path/lib

I update the code, and test manually passed for both mac and window

It may fix #28 (Maybe #20 as well, not checked that too much)

remaining

But I'm not sure the origin logic,
And I know app-root-path is used by tons of libs So I also keep it as comment code,

Please check it Thanks ~

(UPDATE) I notice that CI failed, so maybe we could seperate the use-case somehow?

seognil avatar Jul 03 '19 15:07 seognil

Is this still an issue with 3.0.0?

inxilpro avatar Oct 31 '19 15:10 inxilpro

@inxilpro hi there~
I just tested the v3.0.0, yes it seems still an issue…

notice the case /usr/local/lib/node_modules/@seognil-lab/la-starter-cli/node_modules/app-root-path/lib
there are two node_modules, and the second one is target

seems to need a better way to decide, maybe could use some node.js runtime flag such as __dirname 🤔?

seognil avatar Nov 23 '19 06:11 seognil