question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error when import SCSS from node_modules

See original GitHub issue

I am using Vue CLI webpack starter.

<style lang="scss">
@import '@material/checkbox/mdc-checkbox';
</style>

This gives me an error

in ./~/css-loader?{"minimize":false,"sourceMap":false}!./~/vue-loader/lib/style-compiler?{"vue":true,"id":"data-v-563a1fd0","scoped":false,"hasInlineConfig":false}!./~/sass-loader/lib/loader.js?{"sourceMap":false}!./~/vue-loader/lib/selector.js?type=styles&index=0!./src/components/Checkbox.vue
Module build failed: 
@import '@material/checkbox/mdc-checkbox';
^
      File to import not found or unreadable: @material/checkbox/mdc-checkbox.
Parent style sheet: stdin
      in /home/nman/Documents/WORK/frontend-dev/mdc-vue-integration/src/components/Checkbox.vue (line 72, column 1)
 @ ./~/vue-style-loader!./~/css-loader?{"minimize":false,"sourceMap":false}!./~/vue-loader/lib/style-compiler?{"vue":true,"id":"data-v-563a1fd0","scoped":false,"hasInlineConfig":false}!./~/sass-loader/lib/loader.js?{"sourceMap":false}!./~/vue-loader/lib/selector.js?type=styles&index=0!./src/components/Checkbox.vue 4:14-397 13:3-17:5 14:22-405
 @ ./src/components/Checkbox.vue
 @ ./src/router/index.js
 @ ./src/main.js
 @ multi ./build/dev-client ./src/main.js

What is happening? Why so hard to get started?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:17 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
matspcommented, Aug 24, 2017

Are you building for production or development? Are you extracting CSS in one file or inline it? How does your sourcecode look like? Your package.json? Questions over questions…

Because of that my opinion is that you should get a feeling of webpack without any starter - it is too much magic in the first time.

I will help you but please tear down the destructive mood, it is the mdc repo and not Webpack or Vuejs.

2reactions
jsfeldmancommented, Mar 8, 2018

I ran into a similar problem and it took longer than I care to admit to figure out haha.

If you are using single page components and the new vue-cli, adding this to the vue.config.js should allow a style section set to a lang of scss to look for files in the node_modules folder without the tilda

// vue.config.js
const path = require('path')
const merge = require('webpack-merge')
...
chainWebpack: config => {
  config.module
    .rule('vue')
    .use('vue-loader')
    .tap(options =>
      merge(options, {
        loaders: {
          scss: [
            {
              loader: 'sass-loader',
              options: {
                sourceMap: false,
                includePaths: [path.resolve(__dirname, './node_modules')]
              }
            }
          ]
        }
      })
    )
}

I’m far from a webpack guru so if you have any corrections please let me know.

Read more comments on GitHub >

github_iconTop Results From Across the Web

"Error: Can't find stylesheet to import." · Issue #2499 · vitejs/vite ...
This is caused by vite always using package.json to determine which file to load. In the case of SASS, this will usually (if...
Read more >
SCSS cannot resolve imports (node_modules) in IDE - YouTrack
SCSS cannot resolve imports (node_modules) in IDE - but actually works on ng serve. Running ng serve reports zero issues and also the...
Read more >
Webpack can't resolve @import of scss/css - Stack Overflow
Webpack: getting this error: build failed (from ./node_modules/css-loader/dist/cjs.js):. My Node version was 12.18.3 , where I had the error ...
Read more >
Sass Error after upgrading vom v14 to v15 | Infragistics Forums
The following error appears after updating a simple and lean application form v14 to v15 (angular and infragistics, node JS v18):.
Read more >
Error when importing scss file - Get Help - Vue Forum
Syntax Error: SassError: expected “;” ... I want variables.scss to be recognized and used in a folder root (assets/scss) other than the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found