Saya telah membuat proyek React kosong, menggunakan perintah: npx create-react-app
pada npm v7.0.7 dan Node v15.0.1
Dipasang:
- React v17.0.1,
- node-sass v5.0.0,
Kemudian saya mencoba mengimpor file .scss kosong ke komponen App:
App.js
import './App.scss'
function App() {
return (
<div className="App">
App
</div>
);
}
export default App;
Lempar Kesalahan:
Failed to compile.
./src/App.scss (./node_modules/css-loader/dist/cjs.js??ref--5-oneOf-6-1!./node_modules/postcss-loader/src??postcss!./node_modules/resolve-url-loader??ref--5-oneOf-6-3!./node_modules/s
ass-loader/dist/cjs.js??ref--5-oneOf-6-4!./src/App.scss)
Error: Node Sass version 5.0.0 is incompatible with ^4.0.0.
package.json
{
"name": "react-17-node-sass-5",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.11.5",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
"node-sass": "^5.0.0",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-scripts": "4.0.0",
"web-vitals": "^0.2.4"
},
...
}
}
yarn add node-sass@4.14.1
jauh lebih cepat