2

I am using Homestead on Windows 10 and suddenly as I added a package ran into an issue of npm being broken, for lack of a better word.

There is some kind of problem with node-sass (included with laravel-mix), but I am not sure what. The error is:

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-sass@4.7.2 install: `node scripts/install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-sass@4.7.2 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

This is preceeded by:

node-sass@4.7.2 install /home/vagrant/code/homestead/node_modules/node-sass
node scripts/install.js

fs.js:646
  return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
             ^

Error: EINVAL: invalid argument, open '/home/vagrant/code/homestead/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:669:20)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/home/vagrant/code/homestead/node_modules/node-sass/lib/extensions.js:7:9)
    at Module._compile (module.js:652:30)

I have tried deleting node_modules folder to build it from scratch. It also runs into a symlink error, so I am running npm install with the --no-bin-links option

I am not sure what else to do. I have found nothing on Google so far to help me.

This is a snippet from the logs:

1975 verbose lifecycle node-sass@4.7.2~install: PATH: /usr/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/vagrant/code/homestead/node_modules/node-sass/node_modules/.bin:/home/vagrant/code/homestead/node_modules/.bin:/home/vagrant/.composer/vendor/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
1976 verbose lifecycle node-sass@4.7.2~install: CWD: /home/vagrant/code/homestead/node_modules/node-sass
1977 silly lifecycle node-sass@4.7.2~install: Args: [ '-c', 'node scripts/install.js' ]
1978 silly lifecycle node-sass@4.7.2~install: Returned: code: 1  signal: null
1979 info lifecycle node-sass@4.7.2~install: Failed to exec install script

To add: I have also cleared npm cache (verified and even force cleared), provisioned Homestead several times. This is also actually a new box since the last one refused to come up so I replaced it completely. One of the more recent commands I ran was:

npm audit fix

Could that have broken it? I ran the install on my Windows host on the same folder and it worked without issues. After that it seems the install also works on Homestead. There are a lot of rollbacks but no specific errors anymore. I am still however at a loss as to what went wrong. I should not have to use a Windows machine to correct Linux mistakes.

And to edit again: while running install no longer introduced any errors, I still cannot run it. It doesn't run on Homestead/Linux nor on Windows. So I am still stuck.

TS'
  • 113
  • 1
  • 13
  • Check if node-sass dependencies are installed on your system. https://github.com/nodejs/node-gyp#on-windows – programoholic Jun 18 '18 at 11:31
  • I am on Homestead = Linux. And node-sass is a dependency itself. It has also worked for several months, only now did it start suddenly failing. Maybe something to do with the new Homestead version but as I am new I have not found how to downgrade it and keep it there. For right now I have managed to get at least something running by switching to yarn. I would still like npm to work though since yarn and npm conflict with each other - yarn will complain about the bin folder not being empty (requiring me to shut the vm down to remove it) and npm will complain that something else has been used – TS' Jun 18 '18 at 14:02
  • I was facing the same issue... what you need to do is either use the npm and node version on which code was working previously or make sure the machine has required dependencies which is required to run sass package. – programoholic Jun 19 '18 at 09:35
  • It's so and so. I think maybe switching to yarn in the end will be the way to go. I downgraded to npm 5.7.2. and with --no-bin-links and --ignore-scripts I managed to get things installed again. However `npm run dev` has an issue with `jquery-ui-dist` suddenly. I am getting errors on trying to include images, it seems. It didn't have this before and on yarn run threw no errors on this. So yeah, one step forward, two steps back. – TS' Jun 19 '18 at 16:47
  • OK, installing optipng-bin separately resolved those. So fingers crossed – TS' Jun 19 '18 at 16:54
  • To update then I still have an issue with node-sass on any version of npm after 5.7.x and have been forced to ue the downgraded version which makes 0 sense when the Homstead box is provided entirely by Laravel. Why supply a box that will not work out of the box? – TS' Oct 06 '18 at 12:35
  • Possible duplicate of [Problem when I execute npm install on docker](https://stackoverflow.com/questions/52095320/problem-when-i-execute-npm-install-on-docker) – kenorb Nov 07 '18 at 12:03
  • This is not a duplicate since this was created before. Check your dates – TS' Nov 28 '18 at 04:25

0 Answers0