Error Message: "Unable to locate module component - Storybook with TypeScript"

I'm encountering an issue when running Storybook, specifically this error message:

ERROR in ./components/atoms/input/input.tsx 14:0-40
Module not found: Error: Can't resolve 'react-tagsinput' in '...'

To provide some context about my setup:

Directory Structure

root
|.storybook
  |-main.ts
|-components
  |-atoms
    |-input
      |-input.tsx
      |-input.stories.ts
|-node_modules

Main Configuration (main.ts)

import type { StorybookConfig } from "@storybook/nextjs";

const config: StorybookConfig = {
  stories: ["../components/**/*.mdx", "../components/**/*.stories.@(js|jsx|mjs|ts|tsx)"],
  addons: [
    "@storybook/addon-links",
    "@storybook/addon-essentials",
    "@storybook/addon-onboarding",
    "@storybook/addon-interactions",
  ],
  framework: {
    name: "@storybook/nextjs",
    options: {},
  },
  docs: {
    autodocs: "tag",
  }
};
export default config;

Input Component Stories (input.stories.ts)

import type { Meta, StoryObj } from '@storybook/react';
import Input from './input';

// Code continues...

Input Component Implementation (input.tsx)

import React, { InputHTMLAttributes } from "react";
import TagsInput from 'react-tagsinput';

// Code continues...

Package Dependencies (package.json)

{
  "dependencies": {
    // List of dependencies
  },
  "devDependencies": {
    // List of dev dependencies
  }
}

I've attempted to troubleshoot following suggestions on the Storybook documentation (), but have yet to find a solution. Any assistance would be highly valued.

Answer №1

After some trial and error, I discovered that by installing both @types/react-tagsinput and react-tagsinput, I was able to effectively integrate the module into my projects using Storybook and NextJS. The use of @types/react-tagsinput specifically enabled me to utilize the input component within TypeScript. While this workaround does the job, I am certain there must be a more optimal solution out there. I believe that with some further exploration, I will uncover the proper configuration to address this issue accurately.

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

Guide on how to specify the return type for useMutation in the 'react-query' library

Here is the code snippet provided: const setFriendCode = (data: Params) => api({ data }) const [mutateSetFriendCode, state] = useMutation<Response, Params>( setFriendCode ) An issue arises with the type of parameters in the code. The compiler ...

What is the process for connecting custom transformers to a compiler host?

My custom TypeScript watcher is set up like this: const compilerHost = typescript.createWatchCompilerHost(config.fileNames, config.options, typescript.sys, undefined, reportDiagnostic) typescript.createWatchProgram(compilerHost) I am trying to integrate ...

How can I display a comprehensive list of all properties that an object accepts in WebStorm using TypeScript?

Is it possible to view all properties associated with an object without having to manually type them out? In Visual Studio, this can be done easily. However, in WebStorm, hints only appear when you start typing. I have attempted to adjust the "Inlay hints ...

What is the best way to reach the scope of a constructor that wraps an Angular2 observable?

Below is the code snippet in question: import { Injectable } from '@angular/core'; import { Http, Response, Headers, RequestOptions, URLSearchParams } from '@angular/http'; import { Observable } from "rxjs/Observable"; import { Doc ...

Enhancing AWS Amplify Auth elements using TypeScript

My goal is to enhance the existing Auth components within AWS Amplify like SignIn, SignUp, etc. by customizing the showComponent() function to display a personalized form. I found a helpful guide on how to achieve this at: While working on my nextjs proje ...

Tips for integrating Tesseract with Angular 2 and above

I'm currently exploring the use of Tesseract within one of my components for OCR processing on a file. .ts: import * as Tesseract from 'tesseract.js'; fileToUpload: File = null; handleFileInput(files: FileList) { this.fileToUpload = f ...

Updating CSS class for a label when a radio button is selected in Angular 6

Within my Angular component, I've set up a radio button group like so: <label class="btn-{{cl1}}"> <input type="radio" value="am" name="time" formControlName="time1" (change)="cl1=active" >9:00am </label> I am looking for an effi ...

Attempting to successfully integrate the Prerender SPA Plugin with Vue.js CLI 3

Encountering an issue while attempting to build: Building for production...Error: ENOENT: no such file or directory, stat '/Users/me/Code/project/index.html' Software Package: "prerender-spa-plugin": "^3.1.0" Location: vue.config.js: const Pr ...

What about incorporating unique images with custom HTML input tags?

Hand Diagram Hey there! I'm currently working on a small project using Angular. I was wondering if it's feasible to add tags to an image and prompt the user for input when a tag is clicked? For example, in the image above, I'd like to plac ...

How to import an HTML file using TypeScript

I need to load an html file located in the same directory as the typescript file and return it from the function. public ...(... ) : angular.IHttpPromise<string> { ... return $http({ method: 'GET', url: &apos ...

What are the steps to enable full functionality of the strict option in TypeScript?

Despite enforcing strict options, TypeScript is not flagging the absence of defined types for port, req, and res in this code snippet. I am using Vscode and wondering how to fully enforce type checking. import express from 'express'; const app ...

Traversal of a binary tree in the order of visitation specified by the In

My task was to create a function that traverses a binary tree and returns an array of all its values in inorder. The code provided is: interface BinTree { root: number; left?: BinTree; right?: BinTree; }; const TreeInArray =(t:BinTree):number[] =>{ ...

Error occurs in Azure Function Linux Nodejs when trying to use @azure/storage-blob as it cannot read the property 'startsWith' of undefined

While testing my Azure Nodejs Linux function locally, I encountered this issue with the code snippet below: import { BlobServiceClient } from "@azure/storage-blob"; const connectionString = process.env[ "AZURE_STORAGE_CONNECTION_STRING&qu ...

Issues with Observable<boolean> functionality

Can anyone lend a hand? I'm facing a challenge with this function that is crucial for the application. Typescript File get $approved(): Observable<boolean> { return this.$entries.map(entries => { if (entries.length > 0) { ret ...

Holding off on completing a task until the outcomes of two parallel API requests are received

Upon page load, I have two asynchronous API calls that need to be completed before I can calculate the percentage change of their returned values. To ensure both APIs have been called successfully and the total variables are populated, I am currently using ...

Efficiently managing desktop and mobile pages while implementing lazy loading in Angular

I am aiming to differentiate the desktop and mobile pages. The rationale is that the user experience flow for the desktop page involves "scrolling to section", while for the mobile page it entails "navigating to the next section." The issue at hand: Desk ...

Utilizing lodash and Angular 8: Identifying an valid array index then verifying with an if statement

In my current project, I am developing an e-commerce angular application that includes a basket with two types of products: restaurant + show combos and gift cards. When a client reserves a restaurant, they must also reserve a show; conversely, the client ...

Having trouble retrieving a value from a reference object in React Typescript?

Struggling with a login form issue in my React TypeScript project. Below is the code for the react login form: login-form.tsx import * as React from 'react'; import { Button, FormGroup, Input, Label } from 'reactstrap' ...

Dynamic addition of a Javascript script to a component leads to malfunctioning

I am facing an issue with a dynamically created component where I added the script tag, but unfortunately, the code inside is not functioning properly. Despite trying multiple solutions, none seem to work for me. Could you please review the code? https:// ...

Locating items within an array of objects using Angular 6 with TypeScript or JavaScript

I have the following code in my HTML template for my Angular 6 application. <div *ngIf ="conversation.participants[conversation.updatedBy.toLowerCase()].firstName">somedata </div> My goal is to search within the participants array object base ...