Giter Site home page Giter Site logo

Comments (8)

inxilpro avatar inxilpro commented on July 29, 2024

Can you post what require('module').globalPaths contains in your app?

from node-app-root-path.

goloroden avatar goloroden commented on July 29, 2024

I'll hand it over to a colleague whom I asked this for.

from node-app-root-path.

FrankStraif avatar FrankStraif commented on July 29, 2024

Hi,

require('module').globalPath contains:

[ 'C:\\Users\\jane.doe\\.node_modules', 'C:\\Users\\jane.doe\\.node_libraries', 'C:\\Program Files\\lib\\node' ]

Regards,
Frank

from node-app-root-path.

inxilpro avatar inxilpro commented on July 29, 2024

Thanks, Frank. I'm not entirely sure how nvm handle setting its module path on Windows. It's odd that C:\Users\jane.doe\AppData\Roaming\nvm\v6.7.0\node_modules isn't in that list. What about your NODE_PATH environmental variable? What is that set to?

from node-app-root-path.

FrankStraif avatar FrankStraif commented on July 29, 2024

Hi Chris,
I have not set NODE_PATH (never needed it).
But even setting NODE_PATH to e.g. "C:\Users\jane.doe\AppData\Roaming\nvm\v6.7.0" did not change the behavior, expect that require('module').globalPath now returns

[ '"C:\Users\jane.doe\AppData\Roaming\nvm\v6.7.0"',
'C:\Users\jane.doe\.node_modules',
'C:\Users\jane.doe\.node_libraries',
'C:\Program Files\lib\node' ]

appRootPath.path is still set to "C:\Users\jane.doe\AppData\Roaming\nvm\v6.7.0".


Remember: the module is globally installed:
I now debugged a little bit and in resolve.js line 49 the following happens:

  1. resolved is set to:

c:\Users\jane.doe\AppData\Roaming\nvm\v6.7.0\node_modules\@org\my-app\node_modules\app-root-path

  1. the code does:
var nodeModulesDir = sep + 'node_modules';

if (!alternateMethod && -1 !== resolved.indexOf(nodeModulesDir)) {
	var parts = resolved.split(nodeModulesDir);
	if (parts.length) {
		appRootPath = parts[0];
		parts = null;
	}
}
  1. This is how the parts then look like:
parts:
0:"c:\Users\jane.doe\AppData\Roaming\nvm\v6.7.0"
1:"\@org\my-app"
2:"\app-root-path"
  1. and parts[0] is what is finally returned as appRootPath.path.

Hope this helps.

Thanks,
Frank

from node-app-root-path.

navossoc avatar navossoc commented on July 29, 2024

I have the exactly the same problem (equivalent paths also), but I'm not using nvm or scoped packages.

I'm not sure, but maybe this isn't related to the new "npm flat design packages"?
I'm not a "node expert", so I'm just trying to guess here...

from node-app-root-path.

goloroden avatar goloroden commented on July 29, 2024

Any update on this?

from node-app-root-path.

beanilsson avatar beanilsson commented on July 29, 2024

Still experiencing this. Any updates?

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.