Issue detected in loading ./styles.css in Angular 6

I'm a beginner with Angular 6 and encountered this error in my project:

 ERROR in multi ./node_modules/bootstrap/dist/css/bootstrap.min.css ./styles.css
Module not found: Error: Can't resolve 'C:\Users\User\e-CommerceWebsite\styles.css' in 'C:\Users\User\e-CommerceWebsite'

The browser displays:

cannot Get

In angular.json file:

 "styles": [
          "./node_modules/bootstrap/dist/css/bootstrap.min.css",
          "styles.css"
        ],
        "scripts": [
          "./node_modules/jquery/dist/jquery.min.js",
          "./node_modules/popper.js/dist/popper.min.js",
          "./node_modules/bootstrap/dist/js/bootstrap.min.js"
        ]

Content of styles.css file:

@import '~bootstrap/dist/css/bootstrap.min.css';
...
...
...

Reference to solution: bootstrap not connect to the angular 6?

Seeking assistance to resolve this error.

Answer №1

To resolve the problem in your Angular 6 angular.json file, simply include the bootstrap or font-awesome CSS files as shown below:

   "styles": [
          {
            "input": "./node_modules/bootstrap/dist/css/bootstrap.min.css"
          },
          {
            "input": "./node_modules/font-awesome/css/font-awesome.min.css"
          },
          "src/styles.css"
        ],

Answer №2

The path it's currently taking is incorrect. To correct this, we should specify the path as

../node_modules/bootstrap/dist/css/bootstrap.min.css
rather than just
node_modules/bootstrap/dist/css/bootstrap.min.css
.

Answer №3

It worked perfectly for me!

  "styles": [
         {
            "input": "./node_modules/bootstrap/dist/css/bootstrap.min.css"
          },
          "src/styles.css"
        ],

Answer №4

The solution that finally resolved my issue:

1/   Remove the "node-modules" folder
2/   Run the command "npm install <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1977767d7c346a78a8a565164">[email protected]</a> --save"
3/   Execute "npm install"
4/   Finish with "npm rebuild node-sass"

Answer №5

I encountered a similar issue and found a solution that worked for me:
within the angular.json file, make sure to include one of the following declarations (be mindful of "." and "/"):

"styles": [
          {
            "input": "./node_modules/bootstrap/dist/css/bootstrap.min.css"
          },
          {
            "input": "./node_modules/font-awesome/css/font-awesome.min.css"
          },
          "src/styles.css"
        ],

or

"styles":
         "src/styles.css",
         "node_modules/font-awesome/css/font-awesome.css"       

Remember to rebuild the project in order to see the changes take effect

Answer №6

Encountering the identical issue, I discovered that the solution lies within your file path adjustment. Take a moment to inspect and rectify it in the following manner.

"styles": [
              "node_modules/bootstrap/dist/css/bootstrap.min.css",
              "src/styles.css"

            ],

alternatively, you can try:

"styles": [
          "../node_modules/bootstrap/dist/css/bootstrap.min.css",
          "../src/styles.css"

        ],

Answer №7

The mistake lies in the path taken. Make sure to add src/ before style.css.

"styles": [
              "node_modules/bootstrap/dist/css/bootstrap.min.css",
              "src/styles.css"
            ],

Answer №8

This issue has come up multiple times while starting new projects.

  • Ensure that the location of bootstrap.min.css matches the path specified in the error message and angular.json
  • Remember to stop the application before editing the angular.json file
  • Then, restart the application

The configuration should look like either:

"styles": [
          "src/styles.scss",
          "../node_modules/bootstrap/dist/css/bootstrap.min.css"
],

or

"styles": [
          "src/styles.scss",
          "node_modules/bootstrap/dist/css/bootstrap.min.css"
],

depending on the specific path mentioned in the error message.

Answer №9

Make sure to include Bootstrap in the angular.json configuration file instead of adding it directly to the styles.css file. This is important because Bootstrap is written in SCSS, not CSS.

"styles": [
        "../node_modules/bootstrap/dist/css/bootstrap.min.css",
        "styles.scss"
      ],

Answer №10

It worked like a charm!

"styles": [{
    "input": "./node_modules/bootstrap/dist/css/bootstrap.min.css"
  },
  {
    "input": "./node_modules/ti-icons/css/themify-icons.css"
  },
  "src/assets/icon/icofont/css/icofont.min.css",
  "src/styles.css"
]

Answer №11

Dealing with this particular issue was quite challenging for me. The solution involved carefully examining the path and making adjustments as outlined below:

"styles": [
          "node_modules/@nebular/theme/styles/prebuilt/default.css"
        ],

Answer №12

I encountered a similar issue but found a solution that worked for me.

 "styles": [
          "node_modules/@angular/material/prebuilt-themes/indigo-pink.css",
          "node_modules/bootstrap/dist/css/bootstrap.css",
          "src/sass/styles.scss"
        ],

Additionally, I discovered another approach that also resolved the problem.

"styles": [
          "./node_modules/@angular/material/prebuilt-themes/indigo-pink.css",
          "./node_modules/bootstrap/dist/css/bootstrap.css",
          "src/sass/styles.scss"
        ]

Answer №13

I encountered a similar problem, but found a solution that worked for me.

Within my angular.json file:

"styles": [             
            "src/styles.css"              
        ],

In my styles.css file:

@import "~../node_modules/bootstrap/dist/css/bootstrap.min.css";

Answer №14

When faced with a similar problem, I found a solution by using the following path format without including the dot (.) and slash (/):

"node_modules/bootstrap/dist/css/bootstrap.min.css",

Answer №15

Encountering a similar issue while using ngx-toastr with Angular 8, I found a solution by arranging the .css style references in a specific order within the angular.json file:

        "styles": [
          "node_modules/bootstrap/dist/css/bootstrap.min.css",
          "src/styles.css",
          "node_modules/ngx-toastr/toastr.css" 
        ],
        "scripts": [
        ]

Additionally, I organized the @imports within the styles.css file as follows:

 @import '~bootstrap/dist/css/bootstrap.min.css';
 @import '~ngx-toastr/toastr.css';

Following this structure resolved the issue at hand.

Answer №16

I encountered a similar issue where I attempted to solve it by uninstalling and reinstalling the Bootstrap package, but unfortunately, it did not resolve the problem.

ERROR in multi ../node_modules/bootstrap/dist/css/bootstrap.min.css ./src/styles.css Module not found: Error: Can't resolve 'D:\angular\node_modules\bootstrap\dist\css\bootstrap.min.css' in 'D:\angular\jsonFile'

The path specified in my angualr.json was

"../node_modules/bootstrap/dist/css/bootstrap.min.css"

However, removing the preceding dots from the path ended up being the solution for me.

"node_modules/bootstrap/dist/css/bootstrap.min.css"

Answer №17

One approach to solve the issue is by following these steps:

1. Open up angular.json and navigate to the styles section. Insert the lines below:
   
   "styles": [
              "node_modules/bootstrap/dist/css/bootstrap.min.css",
              "src/styles.css"
            ],

Alternatively, you can try this configuration as well:

     "styles": [
              "node_modules/bootstrap/dist/css/bootstrap.min.css",
              "src/styles.css"
              ],

Give both a shot - the second option did the trick for me.

2. Access the file labeled "styles.css" and include this line of code:

 @import '~bootstrap/dist/css/bootstrap.min.css';

Answer №18

Encountered a similar problem when setting up a fresh angular 7 project. After installation, running npm start triggered an error message: ERROR in multi ./src/styles.sass. To address this issue, I checked the angular.json file:

      "styles": [
         "src/styles.sass"   <--  Identified that I had styles.scss instead of styles.sass
       ],

I simply renamed the file from styles.sass to styles.scss since it was the one existing in the project directory, and then ran npm start once more. This solution successfully resolved the issue for me.

Answer №19

After encountering the same error, I decided to update by using the npm update command. In order to fix the issue, I made some changes to my angular.js file and removed 'F:\xxxx\node_modules\ngx-select-dropdown\dist\assets\style.css' from the styles as the css file was no longer present there. After saving the changes, I stopped my angular cli and ran ng serve again, which resolved the issue and everything started working fine.

You can find more information about this at https://github.com/manishjanky/ngx-select-dropdown/issues/112. The latest version of ngx-select-dropdown does not require the style.css anymore, hence I removed it from my project. That's all.

Answer №20

The issue at hand arises from an incorrect file path.

Consider using "./node_modules/bootstrap/dist/css/bootstrap.min.css" rather than "../node_modules/bootstrap/dist/css/bootstrap.min.css"

Answer №21

In my opinion, the solution to this problem is quite simple. The issue lies in the path. Simply typing down ./ or entering input will not solve it. If you are encountering the error ""ERROR in multi ./node_modules/bootstrap/dist/css/bootstrap.min.css"", it indicates that you have not installed it in the correct location. If you are following instructions from a book or another source, an easy fix would be to open Command Prompt, navigate to your project folder, and install bootstrap there. Alternatively, provide the full path to bootstrap in the angular.json file.

Answer №22

Have you ever wondered why you should modify the angular.json file?

 "styles": ["styles.scss"],
 "scripts": []

Despite this, your global style remains in styles.css

https://i.sstatic.net/ioJXY.png


It is important to have the style.scss file in place. The error is caused by missing the style.scss file.

Answer №23

To include the bootstrap.min.css file in your project, you have two options:

@import ~/bootstrap/dist/css/bootstrap.min.css;

Alternatively, you can add the bootstrap file to the angular.json (or cli.json in Angular 5 and earlier) file under styles [].

"styles": [
        "styles.css",
        "../node_modules/bootstrap/dist/css/bootstrap.min.css"
    ],

Make sure to specify the correct path for the parser to locate where bootstrap is installed.

Answer №24

After making adjustments in angular.json, I successfully updated the styles by changing:

"styles": ["src/styles.css"]

to

"styles": ["styles.css"]

The changes were effective and everything is working smoothly now!

Answer №25

Ensure that the files linked under 'styles' and 'scripts' are present in the node_modules folder. I encountered this issue when updating packages in my project, where some files referenced in the Angular CLI JSON were missing. The problem was resolved by including the necessary files. Hopefully, this information proves helpful.

Answer №26

Could the issue be related to bootstrap? Here's a possible solution: Step 1. Delete "../node_modules/bootstrap/dist/css/bootstrap.min.css" Step 2. Navigate to styles.css Include bootstrap by inserting this line @import "~bootstrap/dist/css/bootstrap.css"; Following these steps resolved the compilation errors I encountered.

Answer №27

Give this command a try:

Try running npm rebuild node-sass

Answer №28

For Angular 6, make sure to remove the line "./node_modules/bootstrap/dist/css/bootstrap.min.css" from your angular.json file in order for it to function properly.

Once you do this, everything should work fine!

Answer №29

Here is what worked for me: "styles": ["./node_modules/bootstrap/dist/css/bootstrap.min.css","src/styles.css"],

Answer №30

The journey began from beyond the confines of the project directory, requiring you to establish a connection to the 'src' and point them towards the 'styles.css' file. Take note:

"src/styles.css"

~Khai Lim

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

Uh oh! An issue occurred: StaticInjectorError(AppModule)[UserformService -> HttpClient] - There seems

After attempting to incorporate a PrimeNG table into my project, I encountered issues with my build. You can view the broken state of my code at https://github.com/BillyCharter87/Tech-O-Dex-UI/tree/BrokeIt I believe the problem arose when I updated my pac ...

What is the best way to ensure that multiple queries are returned in the correct sequence?

In the interface below, there is a search input box along with data displayed. As you type in the search input, the data below filters accordingly. Each letter typed triggers a request to retrieve the relevant data. For instance, if you type "folder," the ...

How to retrieve cookie value from callback response in Angular?

There are two domains: Angular Application: samlapp.domain.com Node Application: samlapi.domain.com When Node calls the callback with the cookie, it redirects to the samlapp application (samlapp.domain.com/landing) Concern: How can I retrieve the cook ...

Exploring TypeORM: Leveraging the In() function within @ManyToMany relationships

There are two main characters in my story: Hero and Villain (their profiles are provided below). How can I utilize the Encounter() method to identify all instances where the Hero interacts with the Villain based on an array of Villain IDs? I am seeking a ...

The error message "printer.node is not a valid Win32 application" indicates that the

I created a node API for my Angular application that utilizes the node-printer package to print PDF files generated by node. However, when I attempted to run my application using nodemon, an error occurred. Error message: "node printer.node is not a val ...

Tips for utilizing favicons-webpack-plugin in Angular 8 applications?

I am attempting to incorporate the jantimon/favicons-webpack-plugin into an Angular 8 project. To achieve this, I'm utilizing the @angular-builders/custom-webpack package to develop a custom webpack configuration. const FaviconsWebpackPlugin = requir ...

Exploring the capabilities of using the injectGlobal API from styled-components in a TypeScript

I've been attempting to utilize the simple injectGlobal API, but I am encountering difficulties getting it to work with TypeScript. Here is my setup in theme.tsx: import * as styledComponents from "styled-components"; import { ThemedStyledComponentsM ...

Using Cypress and JWT, automate the login process for JHipster

Is there a way to automate the bypassing of the JHipster login screen? This is my goal: let jwt_token before(function fetchUser() { cy.request('POST', '/api/authenticate', { username: 'user', password: &a ...

Retrieving the necessary data from my object to perform a sum calculation in angular

Having trouble retrieving an attribute from an array in my code. In my .ts file, I am fetching data from my backend endpoint like this: export class PostFeedComponent implements OnInit { data: any = {}; constructor(private http: HttpClient) { t ...

Is it possible to use non-numeric values as keys in a Typescript Map?

During a lesson: private items: Map<number, string> = new Map(); ... this.items[aNumber] = "hello"; Results in this error message: An element has an any type because the expression of type number cannot be used to index type Map<numbe ...

Troubleshooting problems with permissions when using the AWS IAM assumeRole function with session

Within my aws-cdk application, I am working on setting up a lambda function to assume a specific role and obtain credentials through aws-sts. These credentials need to include a tenant_id tag. AWS CDK Code: Role to be assumed: const pdfUserRole = new Rol ...

Can anyone help me with coloring Devanagiri diacritics in ReactJS?

I am currently working on a ReactJS project and I have come across an issue. I would like for the diacritic of a Devanagiri letter to be displayed in a different color than the letter it is attached to. For example: क + ी make की I was wondering ...

Unable to resolve the FormGroup when using the FormBulider

Currently, I am facing an issue while working with FormBuilder and FormGroup in Angular 2. When I try to submit a form, the form.value that is passed is of type FormGroup. After trying to access my properties and then restarting the lite server, the app f ...

Problem with Typescript compilation in lerna package

Presently, my project is structured with lerna/react/TS setup as shown below: . ├── lerna.json ├── package.json ├── packages │ ├── patient │ │ ├── package.json │ │ ├── src │ │ │ └── ...

What are some creative ways to emphasize certain dates?

Is there a way to customize mui-x-date-pickers to highlight specific days from a Date array with green filled circles around them? I am using new Date and wondering how to achieve this effect. Below is the code snippet I am currently working with: <Dat ...

Verifying the accuracy of a React Component in interpreting and displaying a path parameter

I have the following React/Typescript component that is functioning correctly. However, I am struggling to write a test using testing-library. My goal is to verify that it properly receives the level parameter and displays it on the page: import React from ...

Assign a value to a file input in Angular 6

I'm currently working with Angular 6 and I have a requirement to retrieve an image that is dropped into a div element and assign it as the value of an input type="file" within a form. The process involves the user dropping an image into the designate ...

Organizing Ionic Cards in Alphabetical Order

I'm working on a personal project where I want to implement an alphabetical filter. Each time I create an Ionic card, I intend for it to be filtered by the first name, such as Andre, Amber, Beckc, etc... Here's what I have so far: https://gyazo.c ...

Safari does not display disabled input fields correctly

I have designed a simple angular-material form with various inputs that are organized using angular flex-layout. The form displays correctly in all browsers except for Safari on iOS devices. The problem in Safari arises when loading a form that contains d ...

Select three random items from a string array list along with their corresponding indexes using TypeScript in Angular

Consider this example: I am working with a string array const groceries = [ 'milk', 'coriander', 'cucumber', 'eggplant', 'carrot', 'brinjal', 'on ...