Problem with node-sass on create-react-app

Viewed 3781

Before I post this question, I have tried all of the solution offered down below : ERROR in Cannot find module 'node-sass'

I use create-react-app to create project1 on Windows 10.

My node version : node -v -> v12.16.3

Install node-sass : npm install node-sass@latest

App.js :

import React from 'react';

import "assets/scss/style.scss";


function App() {
  return (
     <div>Hi World</div>
  );
}

export default App;

npm start

Error on the browser : ./src/App.js Module not found: Can't resolve 'assets/scss/style.scss' in 'F:\project1\src'

I'm just wondering why isn't there a simpler and guarentee-to-work way to get this node-sass installed and run. After I searched up for solution on google, it turns out that a lot of people (not only me) are having the same problem.

2 Answers

You just need to flow three steps:

  1. npm install node-sass
  2. change file extension ( .css to .scss )
  3. change any import to .scss
  4. provide proper path for style.scss file( May I know your style.scss path? )
Related