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.

sass: "~" import not resolved to parent node_modules

See original GitHub issue

Type of Issue

[x] Bug Report
[ ] Feature Request

Description

My library use the foundation sites dependency. When I install library as dependency in my main project, foundation sites dep has landed inside root node_modules instead of the library node_modules directory, so my sass import g.e. @import "~foundation-sites/scss/util/util"; not working. NPM > v2 has new installer which flat dependencies as maximally as possible.

BUILD ERROR
File to import not found or unreadable: /home/klimczakk/workspace/oauth-client/node_modules/ng-shared-module/node_modules/foundation-sites/scss/util/util.
Parent style sheet: /home/klimczakk/workspace/oauth-client/node_modules/ng-shared-module/src/core/components/sidebar/sidebar.component.scss
Error: File to import not found or unreadable: /home/klimczakk/workspace/oauth-client/node_modules/ng-shared-module/node_modules/foundation-sites/scss/util/util.
Parent style sheet: /home/klimczakk/workspace/oauth-client/node_modules/ng-shared-module/src/core/components/sidebar/sidebar.component.scss
    at options.error (/home/klimczakk/workspace/oauth-client/node_modules/node-sass/lib/index.js:291:26)

How To Reproduce

Create app with library dependency, which has sass dependency (in my case foundation-sites) and not mentioned in app package.json. Next, import sass file from sass dependency any partial sass file with ~ and build in library postinstall hook.

Expected Behaviour

I think it’s a problem with https://www.npmjs.com/package/node-sass-tilde-importer which search nearest parent node_modules, so ng-packagr couldn’t found dep in root node_modules. Import with ~ could find module not only nearest node_modules.

Version Information

ng-packagr: 1.6.0
@angular/*: 5.0.0
typescript: 2.4.2
rxjs: 5.5.0
node: 8.9.1
npm/yarn: 5.5.1
foundation-sites: 5.4.1

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:12 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
vZanchiVcommented, May 18, 2018

@dherges

i need your help plz, thx for ngpackagr is a amazing lib , but i have a problem

my config :

i use angular 4 an cli 1.6.5 src – app – assets – css _variables.scss

I use in my file angular-cli.json

"stylePreprocessorOptions": {
        "includePaths": [
          "./assets/css"
        ]
      },

so after that i can importe my file variable inside my component.scss.

in ng-package.json i add

"lib": { "entryFile": "public_api.ts", "styleIncludePaths": [ "./assets/css" ],

But when i try to npm run packagr i had this errror

File to import not found or unreadable: variables.

Error: File to import not found or unreadable: variables. at options.error (C:\SIte\RISKOP_SOCLE_UI\orc-kernel-ui\src\main\ui\node_modules\node-sass\lib\index.js:291:26)

i don’t find a solution, you can help me plz plz ?

1reaction
ennovumcommented, Apr 9, 2018

@dherges sorry to bug you, but is there a timeline for fixing this one? It’s blocking my team and I’d like to know if it makes sense to wait.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Webpack can't resolve @import of scss/css - Stack Overflow
I was trying to do it the native CSS way (MDN), but SCSS might have been ... @import by SCSS is also deprecated...
Read more >
SCSS import paths cannot be resolved
I have a solution. You need to right-click a directory that is a PARENT of directories from which you import. So if your...
Read more >
Sass: @use
Any styles loaded this way will be included exactly once in the compiled CSS output, no matter how many times those styles are...
Read more >
SPFx Error Running Sample - Error: File to import not found or ...
Error: File to import not found or unreadable: node_modules/office-ui-fabric-react/dist/sass/References. Parent style sheet: C:<my local ...
Read more >
Vue CLI3 Webpack Config for SCSS Imports - Syncfusion
... Webpack Config for SCSS Imports - Top-level selectors may not contain the parent ... path.resolve(__dirname, 'node_modules/@syncfusion'). ].
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