npm Community Forum (Archive)

The npm community forum has been discontinued.

To discuss usage of npm, visit the GitHub Support Community.

Provide an option to define in what directory the module will be resolved.

Hi everybody, i’m Joan Peralta, this is my first idea in the NPM community, I hope everybody have a good day.

The problem:

import CustomTable from '@myOrganization/components/build/CustomTable';

The possible solution:
Provide an option in the package.json that defines in what directory the module should be resolved, something like:

{ "name": "@myOrganization/components", "version": "0.0.1", "resolveModuleFrom": "./build", "depedencies": ... }

Then when I can use:

import CustomTable from '@myOrganization/components/CustomTable';

And the file CustomTable.js should be resolved in the build folder.

I hope to read your answers.

Side note: there is a package-name-maps proposal to use packages based on a custom mapping. It doesnt specifically cover your use case yet, but if the node team implements it, it may be worth adding your use case as a feature there.