kristerkari / react-native-sass-transformer

Use Sass to style your React Native apps.
MIT License
219 stars 19 forks source link

Unable to resolve module `./sidebar.module.scss` from `/*****/sidebar.module.js`: The module `./sidebar.module.scss` could not be found from `/*****/sidebar.module.js`. Indeed, none of these files exist: #22

Closed Temkit closed 5 years ago

Temkit commented 5 years ago

After following the documentation, i have an error when importing the scss file : import sidebarStyles from "./sidebar.module.scss"; of course the files exist and in the right path, double checked everything multiple times.

the complete error :

error: bundling failed: Error: Unable to resolve module ./sidebar.module.scss from /Users/knewtone/OneDrive/knewtone.com/projects/WorkSpace/app/keina/app/src/sidebar/sidebar.module.js: The module ./sidebar.module.scss could not be found from /Users/knewtone/OneDrive/knewtone.com/projects/WorkSpace/app/keina/app/src/sidebar/sidebar.module.js. Indeed, none of these files exist:

/Users/knewtone/OneDrive/knewtone.com/projects/WorkSpace/app/keina/app/src/sidebar/sidebar.module.scss(.native||.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx) /Users/knewtone/OneDrive/knewtone.com/projects/WorkSpace/app/keina/app/src/sidebar/sidebar.module.scss/index(.native||.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx) at ModuleResolver.resolveDependency (/Users/knewtone/OneDrive/knewtone.com/projects/WorkSpace/app/keina/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:163:15) at ResolutionRequest.resolveDependency (/Users/knewtone/OneDrive/knewtone.com/projects/WorkSpace/app/keina/node_modules/metro/src/node-haste/DependencyGraph/ResolutionRequest.js:52:18) at DependencyGraph.resolveDependency (/Users/knewtone/OneDrive/knewtone.com/projects/WorkSpace/app/keina/node_modules/metro/src/node-haste/DependencyGraph.js:283:16) at Object.resolve (/Users/knewtone/OneDrive/knewtone.com/projects/WorkSpace/app/keina/node_modules/metro/src/lib/transformHelpers.js:261:42) at /Users/knewtone/OneDrive/knewtone.com/projects/WorkSpace/app/keina/node_modules/metro/src/DeltaBundler/traverseDependencies.js:399:31 at Array.map () at resolveDependencies (/Users/knewtone/OneDrive/knewtone.com/projects/WorkSpace/app/keina/node_modules/metro/src/DeltaBundler/traverseDependencies.js:396:18) at /Users/knewtone/OneDrive/knewtone.com/projects/WorkSpace/app/keina/node_modules/metro/src/DeltaBundler/traverseDependencies.js:269:33 at Generator.next () at asyncGeneratorStep (/Users/knewtone/OneDrive/knewtone.com/projects/WorkSpace/app/keina/node_modules/metro/src/DeltaBundler/traverseDependencies.js:87:24)

Temkit commented 5 years ago

Issue resolved after installing :

"postcss": "^7.0.16",
"postcss-css-variables": "^0.12.0",
"postcss-loader": "^3.0.0",
"react-native-postcss-transformer": "^1.2.4"

can someone explain what hapened here ?

kristerkari commented 5 years ago

@Temkit Thanks for this.

I can't say for sure without seeing your project, but one usual suspect is that you need to restart the packager after adding new files to your project. For some reason the Metro packager does not seem to find the files that are added without a restart.

Let me know if you still have issues or if you want me to have a look at your project.

cobyfielding commented 4 years ago

I am receiving this same error, Unable to resolve module styles.scss.... after updating expo-cli to 3.0.9. I have followed the documentation and have added the metro.config.js file as shown in the documentation. I have tried adding the packages mentioned above but nothing I have tried has made any difference. I have tried different versions of node when yarn installing and still get the error when loading the app in the simulator. I am not really sure what to share because everything was working perfectly until the cli update. Any chance you can help point me in the right direction, or tell me what information you might need to help debug? Thanks for your time

kristerkari commented 4 years ago

Oh yeah Expo made a breaking change, so the docs need to be updated. Here are the updated docs from the SVG transformer: https://github.com/kristerkari/react-native-svg-transformer#for-react-native-v057-or-newer--expo-sdk-v3100-or-newer

kristerkari commented 4 years ago

So @cobyfielding you need to add the sourceExts field to app.json to fix the issue.

cobyfielding commented 4 years ago

Awesome!!! Thank you so much @kristerkari. Do you have a patreon account?

kristerkari commented 4 years ago

You're welcome :)

Do you have a patreon account?

I don't, but there are plenty of other open source projects and people working with open source that need support, so please donate to them instead. 👍