bobdolan
bobdolan

Reputation: 573

npm cannot install 'node-sass'

I'm trying to run a project with npm start and then get the following error in a bunch of different components:

Module build failed: Error: Cannot find module 'node-sass'

Alright, I'm thinking and I run 'npm install node-sass', which then leaves me with the following error:

Error: EINVAL: invalid argument, open '/usr/app/client/node_modules/node-sass/package.json'
    at Object.fs.openSync (fs.js:646:18)
    at Object.fs.readFileSync (fs.js:551:33)
    at Object.Module._extensions..json (module.js:670:20)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
    at Module.require (module.js:597:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/usr/app/client/node_modules/node-sass/lib/extensions.js:7:9)
    at Module._compile (module.js:653:30)

I don't know what it means or what I can do to resolve it, I tried commands like npm rebuild, npm uninstall and then install again, deleted the node_modules folder but that doesn't seem to do the trick.

Upvotes: 4

Views: 24521

Answers (5)

user18033520
user18033520

Reputation: 1

None of those options worked for me. I was trying to install node-sass version 4.14.1 and this seemed to work:

  1. git clone --recursive https://github.com/sass/node-sass.git
  2. cd node-sass
  3. npm install
  4. node scripts/build -f
  5. cd ..
  6. npm install node-sass --sass-binary-path=C:\Users<you-path>\node-sass\vendor\win32-x64-93\binding.node

That seemed to work for me. But then after all that effort, v.4.14.1 was incompatible with another package so I was ready to flip a table by that point < insert-table-flipping-meme >.

Upvotes: 0

Moshe Peled
Moshe Peled

Reputation: 1

npm install --unsafe-perm node-sass

in Linux:

sudo npm install --unsafe-perm node-sass

Upvotes: 0

Deepanshu Wadhwa
Deepanshu Wadhwa

Reputation: 21

Try running :

npm install node-sass --force 

It would work.

Upvotes: 1

Kishan Patel
Kishan Patel

Reputation: 803

I think this would work.
The package.json I have was written like the following.

"devDependencies": {
    ...
    "node-sass": "^4.5.0",
    ...
  }

npm install node-sass
npm install node-sass@latest
npm rebuild node-sass --force
npm install node-sass --force

Upvotes: 13

bobdolan
bobdolan

Reputation: 573

Ok, so the solution to my specific problem was:

npm install node-sass --force

and then I had to do

npm rebuild node-sass --force

And then I got it to compile

Upvotes: 6

Related Questions