During the development of my package, I have organized my repository with the following structure:
src
- Requests.js
- Constants.js
package.json
The package.json
file contains the following information:
{
"name": "package-name",
"version": "1.0.0",
"main": "src/Requests"
}
To access my module in the project, I use the following method:
import Requests from 'package-name';
However, I am facing an issue when trying to import the Constants
class from the package. The compiler throws an error stating that the class cannot be found.
import Constants from 'package-name/Constants';
In order to make it work, I had to include /src
in the import path like this:
import Constants from 'package-name/src/Constants';
I attempted to modify the main
field in my package.json
to just the directory name, but it did not resolve the issue:
"main": "src/"