Search code examples
reactjscreate-react-appnode-sassreact-tsx

Cannot find module 'delegates' in CRA yarn add node-sass


I have created a fresh app with CRA and want to add Sass support according to its official description which simply says to add it with yarn add node-sass

but this throws an error

error /home/.../frontend/node_modules/node-sass: Command failed.
Exit code: 1
Command: node scripts/install.js
Arguments: 
Directory: /home/.../frontend/node_modules/node-sass
Output:
module.js:550
    throw err;
    ^

Error: Cannot find module 'delegates'
    at Function.Module._resolveFilename (module.js:548:15)
    at Function.Module._load (module.js:475:25)
    at Module.require (module.js:597:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/home/amir/WORKSPACE/daypay/daypay_v2/frontend/node_modules/are-we-there-yet/tracker-stream.js:4:16)
    at Module._compile (module.js:653:30)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)

Solution

  • I dont know why but it seems node_modules where messed up though it was a new created app.

    SO I hard coded the node-sass and @types/node-sass in package.json deleted the yarn.lock or (package-lock) and node_modules folder and run yarn install again