1

I had to reformat my windows C drive and reinstall windows now suddenly all of my angular projects I'm working on are having this issue! I've tired several things in attempt to fix it such as deleting the node modules folder in the app and nothing seems to work.

I have already attempted these fix methods and they both failed:

npm install --save-dev webpack webpack-dev-server css-loader sass-loader node-sass extract-loader file-loader

npm install --save-dev --unsafe-perm node-sass

ERROR in ./src/styles.scss (./node_modules/@angular-devkit/build-angular/src/angular-cli-files/plugins/raw-css-loader.js!./node_modules/postcss-loader/src??embedded!./node_modules/sass-loader/dist/cjs.js??ref--14-3!./src/styles.scss)
Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
ValidationError: Invalid options object. Sass Loader has been initialised using an options object that does not match the API schema.
 - options has an unknown property 'includePaths'. These properties are valid:
   object { implementation?, sassOptions?, prependData?, sourceMap?, webpackImporter? }
    at validate (E:\Work\MyApp\Eng\stage\frontend\MyApp\node_modules\sass-loader\node_modules\schema-utils\dist\validate.js:50:11)
    at Object.loader (E:\Work\MyApp\Eng\stage\frontend\MyApp\node_modules\sass-loader\dist\index.js:36:28)
ERROR in ./src/app/app.component.scss
Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
ValidationError: Invalid options object. Sass Loader has been initialised using an options object that does not match the API schema.
 - options has an unknown property 'includePaths'. These properties are valid:
   object { implementation?, sassOptions?, prependData?, sourceMap?, webpackImporter? }
    at validate (E:\Work\MyApp\Eng\stage\frontend\MyApp\node_modules\sass-loader\node_modules\schema-utils\dist\validate.js:50:11)
    at Object.loader (E:\Work\MyApp\Eng\stage\frontend\MyApp\node_modules\sass-loader\dist\index.js:36:28)
ERROR in ./src/app/welcome/welcome.component.scss
Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
ValidationError: Invalid options object. Sass Loader has been initialised using an options object that does not match the API schema.
 - options has an unknown property 'includePaths'. These properties are valid:
   object { implementation?, sassOptions?, prependData?, sourceMap?, webpackImporter? }
    at validate (E:\Work\MyApp\Eng\stage\frontend\MyApp\node_modules\sass-loader\node_modules\schema-utils\dist\validate.js:50:11)
    at Object.loader (E:\Work\MyApp\Eng\stage\frontend\MyApp\node_modules\sass-loader\dist\index.js:36:28)
Robert
  • 343
  • 6
  • 16
  • Did you try `npm install`? `npm isntall --save-dev --unsafe-perm node-sass` only install the node-sass dependency. You need to probably `npm install` – Jason White Oct 31 '19 at 19:53
  • lol of course I tried that even going as far as deleting the entire folder and re running npm install. – Robert Oct 31 '19 at 19:54
  • 1
    have you tried on another pc as well / on a vm? just to verify that it isn't some miconfiguration on your newly installed pc? – JoSSte Oct 31 '19 at 19:57

4 Answers4

2

It may be because before the new Windows install you had different version of Node. You downloaded the newest node, but your node-sass is still trying to build with the old version. Try "npm rebuild node-sass --force". After running this your app should work.

  • Unfortunately that did not work either. I was able to get another project fixed by running npm install --save-dev --unsafe-perm node-sass however on this project it doesn't seem to work. – Robert Oct 31 '19 at 20:53
2

In my case the problem was, that I explicitly installed:

  • node-sass
  • css-loader
  • sass-loader
  • style-loader

so they were listed inside package.json dev-dependencies. After removing them from there, deleting node_modules and npm install again, my Angular app worked again.

I could imagine that Angular uses its own version of those packages and when installing them explicitly in package.json (with maybe another version) it runs into those issues (I'm probably wrong here, just an assumption).

It would explain, why swapping the OP's package.json worked for him as well.

jlang
  • 929
  • 11
  • 32
1

I am uncertain completely which item helped the most here as all of the information posted above was very useful. Ultimately deleting the package.json lock file and then completely replacing the package.json file with a separate Json file that worked on another project seems to have fixed the issue. After deleting the node_modules folder and then running npm install. Thank you everyone for your help!

Robert
  • 343
  • 6
  • 16
0

I solved my issue deleting the node_modules folder (you can do it with cmd so it wont take so long), after that npm i again, then npm i -S node-sass and it worked!