External CSS styles brought in by an external module

Currently, I'm working on a project using Nextjs/Express with TypeScript. I encountered an issue when I introduced the MDEditor component to my pages/sheets/text-editor.tsx file:

import MDEditor from "@uiw/react-md-editor";

const TextEditor: React.FC = () => {
  return (
    <div>
      <MDEditor />
    </div>
  );
};

export default TextEditor;

The error message that popped up was as follows:

./node_modules/@uiw/react-markdown-preview/lib/esm/styles/markdown.css Global CSS cannot be imported from within node_modules. Read more: https://nextjs.org/docs/messages/css-npm Location: node_modules/@uiw/react-markdown-preview/lib/esm/index.js

I suspect this may have occurred due to adding Tailwind to my project following the guidelines provided in this documentation:

https://tailwindcss.com/docs/guides/nextjs

Can someone shed some light on what exactly is happening here?

Answer №1

I stumbled upon some helpful documentation:

npm install next-remove-imports
npm install @uiw/react-markdown-editor
// next.config.js
const removeImports = require('next-remove-imports')();
module.exports = removeImports({
//original content of next.config.js
});
// component.jsx
import dynamic from 'next/dynamic';
import '@uiw/react-markdown-editor/markdown-editor.css';
import '@uiw/react-markdown-preview/markdown.css';

const MarkdownEditor = dynamic(
  () => import("@uiw/react-markdown-editor").then((mod) => mod.default),
  { ssr: false }
);

function HomePage() {
  return (
    <div>
      <MarkdownEditor value="Hello Markdown!" />
    </div>
  );
}

export default HomePage;

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

I'm not sure if I'm doing this right, the image seems to be overlapping the border

Just dipping my toes into the world of HTML/CSS, so feel free to point out any major errors in my code. The issue I'm facing is illustrated in this image (Apologies for the black boxes covering up some content; focus is on the top image). Check out ...

Creating a Custom Progress Bar with Bootstrap

I'm encountering an issue with aligning a Bootstrap 3 progress bar vertically within a table cell. While I have successfully aligned other cells to the middle, the progress bar still remains in its original position. How can I eliminate the excess spa ...

Issues with functionality of React/NextJS audio player buttons arise following implementation of a state

I am currently customizing an Audio Player component in a NextJs application using the ReactAudioPlayer package. However, the standard Import Next/Audio and using just <Audio> without props did not yield the expected results. The player functions as ...

What could be causing my JavaScript to malfunction after clicking on anchor links?

My website's JavaScript has a bug where clicking the links in the static header causes scrolling to become buggy and unbearable. What can I do to fix this issue? Thank you in advance. Here is my code: $(window).load(function(){ $(windo ...

Leveraging node.js and express for incorporating custom stylesheets and scripts

I recently designed a webpage with the following elements at the beginning: <link href="./css/font-awesome.min.css" rel="stylesheet"> <link href="http://fonts.googleapis.com/css?family=Open+Sans:400italic,600italic,400,600" rel="stylesheet ...

Bootstrap: Easily align elements to the right with the .pull-right class, avoiding the need to manually adjust margins

This is the code snippet I am working with (you can view the fiddle here): <div class='container'> <div class='hero-unit'> <h2>Welcome</h2> <p>Please log in</p> <div i ...

Print Preview Layout in CSS for Optimal Margins

I'm having trouble adjusting the margin sizes on a page in Internet Explorer 11 Print Preview. I also want to remove any content from the margins (such as page numbers, titles, URLs, etc). I've successfully set the margin size, but I can't ...

JavaScript powered simple window

I am currently working on a basic modal that will open and display content. Unfortunately, I cannot add images to help illustrate the design, so I'll do my best to describe it in detail. The modal is linked to an image slider where the heading change ...

The import error occurred because the module 'styled-components' does not export 'createGlobalStyle'

I am encountering an issue while attempting to import createGlobalStyle from styled-components. Despite having installed the styled-components npm package with version @3.4.10, it doesn't seem to work as expected. const GlobalStyle = createGlobalStyl ...

On smaller screens in portrait mode, CSS automatically incorporates margin adjustments

Here is the code I am working with: <html> <head> <style> body { margin: auto; width: 720px; } </style> </head> <body> <p>Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet. Lorem ip ...

Customize a Bootstrap 4 card-deck layout to adjust the number of columns based on the viewport

I am currently working on implementing the card-deck feature in Bootstrap 4 to ensure that all my cards have the same height. Although the examples provided by Bootstrap showcase 4 stylish cards, they are always displayed as 4 cards per row, regardless of ...

Using Material-UI to showcase a TextField with a labelWidth set to zero

I need to showcase a specific field on my website. https://i.stack.imgur.com/PJUW7.png However, the issue I'm facing is that even when the field is in focus, the border remains unaffected and does not get cut off by the label. https://i.stack.imgur ...

HTML validation produces mistakes

I encountered an issue when using Google Fonts and received the following error related to a specific link: <link href="http://fonts.googleapis.com/css?family=Lato:100,300,400,700,900,100italic,300italic,400italic,700italic,900italic|Montserrat:700|Mer ...

Python Selenium error: NoSuchElementException - Unable to find the specified element

Coding Journey: With limited coding knowledge, I've attempted to learn through various resources without much success. Now, I'm taking a different approach by working on a project idea directly. The goal is to create a program that interacts wi ...

What might be causing my grid columns to move onto a new line?

I am facing an issue with my Bootstrap 4 buttons. I have set them up to be 4 columns each within a grid, expecting them to all remain on the same row. However, the third button is dropping down to the next line and I can't seem to figure out why. Her ...

Looking for a Plugin that Can Responsively Display Images in a Vertical Layout - Does One Exist using Jquery

Looking for a gallery slider plugin that is responsive both horizontally and vertically. Have tried Flexslider1/2, Galleria, and others but they do not adjust to vertical resizing. Changing the CSS did not help. If you resize the browser horizontally with ...

One div is experiencing trouble with the `align-items: center` property, while the other divs are functioning

Presenting my React component: <div className='sidebar'> <div className="sidebarItem"> <span className="sidebarTitle">About Me</span> <img src="https://wallpapera ...

Building a Dynamic CSS Grid

Today is the first time I'm reaching out for help rather than figuring things out on my own. I'm currently working on a website layout that consists of visible tiles all with equal sizes, forming a grid structure. The challenge I face is making t ...

Building a Vuetify footer with perfectly centered content: A step-by-step guide

I currently have a setup where I am using the v-flex with a grid ratio of 2 / 8 / 2. This places my content in the center of the section with a width of 8, but the issue is that this centered content does not match up with the other elements on the website ...

Ensure that div2 remains aligned with the left, bottom, and right edges of the screen, while also maintaining a consistent distance of 400px below div

Currently, I am faced with a challenge involving two divs: one positioned at the top (div1) and the other at the bottom (div2). The goal is to ensure that div2 maintains a consistent distance of 400px below div1 while also aligning its left, bottom, and r ...