The use of aliases is not supported by a published node module

I have a project built using create-react-app and it's utilizing react-app-rewired/react-scripts-ts. Within my tsconfig file, I've configured it as follows:

baseUrl: "src",
paths: {
    "src/*": "./*"
}

In many files within this project, the paths are resolving correctly:

import { MyComponent } from "src/components/MyComponent";

This project has been packaged and imported into another application, which specifies in its package.json:

"my-custom-app": "^0.1.0"

However, the main application encounters an error stating that it cannot locate "src/components/MyComponent" in the child app. When I switch to using relative paths in the child app, everything works smoothly.

Could it be an issue with the configuration or are absolute paths not supported when creating npm modules?

A similar problem arises during local development, where sass doesn't seem to load properly. The child app includes a config-overrides.js file:

const rewireSass = require("react-app-rewire-scss");
module.exports = function override(config, env) {
    config = rewireSass(config, env);
    ...
}

Copying this setup into the parent app enables sass loading. I aim for both apps to operate independently, but it seems like the configurations are not being applied correctly in the child app.

Answer №1

Make sure your baseUrl is set to src and that the paths are relative to src. If not, you may end up pointing to src/src instead:

"baseUrl": "src",
"paths": {
  "src/*": [ "../*" ],
},

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Using a click event to target the next div and apply a CSS class using Typescript

I am trying to create a Typescript function that will locate the next div and apply a CSS class to it. Here is what I have attempted: <ul> <li><a href="#" onclick="toggle()">Item 1</a></li> <div class="content hide ...

Is there a way to pass around jest mocks across numerous tests?

In my test scenarios, I've created a mock version of the aws-sdk, which is functioning perfectly: jest.mock("aws-sdk", () => { return { Credentials: jest.fn().mockImplementation(() => ({})), Config: jest.fn().mockImplementati ...

The size of the generated file from tailwind build is compact

I've been working with TailwindCSS and have followed the installation process outlined below. However, after completing the steps, I ended up with a tailwind.css file that only contains 369 lines. This seems to be fewer lines than what others have in ...

There was an issue with matching the call for formatting the start date to "dd MMMM yy" in the function

Hey there, while deploying my project, I encountered this error: https://i.sstatic.net/kiXLA.png Error: No overload matches this call. Overload 1 of 4, '(value: string | number | Date): Date', resulted in the following error: Argument with ...

Sign out from Azure Active Directory using the ADAL library in an Angular application written in TypeScript

When navigating multiple tabs in a browser, I am encountering an issue with logging out using adal. How can I successfully log out from one tab while still being able to use another tab without any hindrance? Currently, when I log out from one tab, it pr ...

Tips for converting numerical values in a JSON object to strings within a TypeScript interface

{ "id": 13, "name": "horst", } in order to interface A { id: string; name: string; } When converting JSON data of type A to an object, I expected the conversion of id from number to string to happen automatically. However, it doesn' ...

Is there a different term I can use instead of 'any' when specifying an object type in Typescript?

class ResistorColor { private colors: string[] public colorValues: {grey: number, white: number} = { grey: 8, white: 9 } } We can replace 'any' with a specific type to ensure proper typing in Typescript. How do we assign correct ...

Error encountered with TypeScript template literals strings type

There's a new feature in the latest version of Typescript that allows the use of template literal strings as types, like this: type Hey = 'Hey'; type HeyThere = `${Hey} There`; It works perfectly in the Typescript playground with version 4 ...

Structured similar to a map with typed elements

As a beginner in Typescript, I am delving into creating a typed map structure where the values are associated with specific keys. This can be demonstrated through pseudo JS code without types: const propertyA = "PropertyA"; const propertyB = "PropertyB"; ...

How can I fetch only the data for the current month in Sequelize using Node

Is there a way to filter data for the current month only using this query? app.get("/api/timesheet_employerId", function (req, res) { console.log("I am the employerId", req.user.id) db.TimeSheet.findAll({ include: [ ...

Tips for sending a query using the http GET method in Next.JS 14 API routes

When using the Next.js 14 API route, I am passing a page in the GET method to paginate the data fetched from my database. However, an error is thrown when trying to retrieve the query from the request: Property 'query' does not exist on type &a ...

Testing the selection of dropdown values in Angular2 using unit tests

I have a dropdown menu for selecting countries. It defaults to a pre-selected value, and when the user changes it, they are redirected to the corresponding country page. However, I am facing an issue while trying to unit test the default value in the sele ...

Issue with Angular 7: "Unspecified name attribute causing control not found"

As I delve into the creation of my initial Angular application, I find myself faced with a series of errors appearing in the development mode console: ERROR Error: "Cannot find control with unspecified name attribute" ERROR Error: "Cannot f ...

Why does the Angular page not load on the first visit, but loads successfully on subsequent visits and opens without any issues?

I am currently in the process of converting a template to Angular that utilizes HTML, CSS, Bootstrap, JavaScript, and other similar technologies. Within the template, there is a loader function with a GIF animation embedded within it. Interestingly, upon ...

Issues arise when using the bootstrap-editable library alongside the Karma Test Runner due to conflicts with undefined objects

Despite searching extensively, I have not been able to find a solution to my specific issue among the many threads on this topic. Most of the solutions mentioned seem to pertain to Angular or other unrelated problems. My ReactJS project is using node v6.5 ...

Issue with TypeScript error encountered when attempting to save data locally using React-Redux and LocalStorage

Currently, I am delving into the worlds of React-Redux and TypeScript. Within my small app, I aim to utilize localStorage to store data locally. I attempted to address this based on information from this particular answer, but ran into a TypeScript erro ...

What is the best method for altering a route in React while utilizing Typescript?

I recently started coding along with the ZTM course and am working on a face recognition app. Instead of using JavaScript, I decided to use TypeScript for this project in order to avoid using the any type. However, as a beginner in this language, I'm ...

Trouble with yarn not functioning properly when using a Nexus 3 npm proxy repository

I have configured a Nexus 3 Manager to serve as a host for private npm packages. Within the nexus are three npm repositories: one labeled hosted, another as proxy, and a third named group which combines the former two. The npm bearer realm has been activat ...

Creating an offline private registry with verdaccio can be achieved by following these steps

One of my recent projects involved setting up a private npm registry using verdaccio. I needed to ensure that running npm install --registry="http://localhost:4873" would fetch all dependencies from the private registry. To achieve this, I had to publish ...

The component is no longer able to locate the imported element when it is being shared

Recently, I imported a component into the shared module in order to use it across 2 different modules. However, upon recompiling the app, an error message appeared stating that the jodit-editor, which is utilized by the shared component, is not recognized ...