Cannot find module path

Hello guys,

I’ve tried to reinstall my application from my distant server to my local machine, and I’m struggling with a ‘Cannot find module : path’ error since then which breaks my application client side.
I don’t understand the problem, please can someone help me with that, it seems that any code that is using : const path = require('path'); is not working.

Does any one something about that ?

Edit : Using meteor npm install --save path made it work, but if anyone can explain to me while path isn’t bundled, it would be cool :slightly_smiling_face:

Is this on the client or server that you get this error?

'path' is a native module in Node environments only, so it won’t be available on the client by default.

The easiest way to get everything working is to install meteor-node-stubs:

meteor npm install meteor-node-stubs

This will make most node-only native modules available on the client as well.

Even better, Meteor is smart enough to only ship the modules you use to the client!

I’m getting the error on the client, and no error is shown on the server.

Yeah, I know that path is a native module in Node and I already have meteor-node-stubs@0.4.1 installed.
This is why I don’t understand it complains about not finding it on the client :confused:

Moreover, this worked previously on my distant machine, I just moved the code to my local one and it stopped working for no apparent reason.
I’ve written an NPM package calls handypixi which encapsulate PIXI, the NPM 2D library using path on the client, and there is a known issue about path not being bundled on the client available here.
However, this was working previously and I thought Meteor bundled any detected module directly on the client. Perhaps it does not detect native module used by NPM packages and thus do not bundle path directly ?

Erm, I may be wrong here: But considering the sandboxing any browser does for security reasons, I’m not seeing too much use for the path module on a client.

Didn’t mean to come across as patronising, just starting with the basics.

Yeah that is weird. require('path') works fine for me in the client without doing anything.

looking at the code PIXI ships through npm, it should easily be able to find that dependency with static analysis

I’ll try to replicate in a new project

Having a dependency that requires ‘path’ means you don’t get much choice about using ‘path’ or not

1 Like

Worked straight out of the gates for me:

How are you importing PIXI in your project?
Is it behind a dynamic import?

No problem, you were right to start with the basics, you almost made me doubt if the package was installed so it was worth the check :smile:

I’m using pixi through an NPM package my company developed which is importing Pixi itself.
The package is named handypixi and just provide regular abstraction on top of pixi.

I’m gonna do more test by removing the npm path package to see if it magically resolves, and get back at you.
Can you try using handypixi instead of pixi in your repro ? :slight_smile:

Sure thing:

No errors encountered

Don’t know what to tell you :man_shrugging: :laughing: