ERROR in ./node_modules/css-loader?

2020-06-01 07:36发布

问题:

I was trying to run an angular project in windows 10. It is the same project that I am doing in Ubuntu. When I clone the repository and install all the node packages I encountered this error.

ERROR in ./node_modules/css-loader?{"sourceMap":false,"importLoaders":1}!./node_modules/postcss-loader?{"ident":"postcss"}!./node_modules/sass-loader/lib/loader.js?{"sourceMap":false,"precision":8,"includePaths":[]}!./src/scss/style.scss Module build failed: Error: ENOENT: no such file or directory, scandir 'C:\Users\Jaaayz\Documents\ad-fingerprinting\web\node_modules\node-sass\vendor' at Object.fs.readdirSync (fs.js:911:18) at Object.getInstalledBinaries (C:\Users\Jaaayz\Documents\ad-fingerprinting\web\node_modules\node-sass\lib\extensions.js:124:13) at foundBinariesList (C:\Users\Jaaayz\Documents\ad-fingerprinting\web\node_modules\node-sass\lib\errors.js:20:15) at foundBinaries (C:\Users\Jaaayz\Documents\ad-fingerprinting\web\node_modules\node-sass\lib\errors.js:15:5) at Object.module.exports.missingBinary (C:\Users\Jaaayz\Documents\ad-fingerprinting\web\node_modules\node-sass\lib\errors.js:45:5) at module.exports (C:\Users\Jaaayz\Documents\ad-fingerprinting\web\node_modules\node-sass\lib\binding.js:15:30) at Object. (C:\Users\Jaaayz\Documents\ad-fingerprinting\web\node_modules\node-sass\lib\index.js:14:35) at Module._compile (module.js:624:30) at Object.Module._extensions..js (module.js:635:10) at Module.load (module.js:545:32) at tryModuleLoad (module.js:508:12) at Function.Module._load (module.js:500:3) at Module.require (module.js:568:17) at require (internal/module.js:11:18) at Object. (C:\Users\Jaaayz\Documents\ad-fingerprinting\web\node_modules\sass-loader\lib\loader.js:3:14) at Module._compile (module.js:624:30) @ ./src/scss/style.scss 4:14-195 @ multi ./src/scss/style.scss

I tried googline it and do everything about it but didn't find any solution.

node -v 8.5.0

Angular CLI version 1.4.3

Appreciate if someone calp help. Thanks in advance.

回答1:

try using

npm rebuild node-sass



回答2:

$ npm install --save node-sass

This does the same as above. Similarly to the answer above.



回答3:

I am also facing the same problem, but I resolve.

npm install node-sass  

Above command work for me. As per your synario you can use the blow command.

Try 1

 npm install node-sass

Try 2

remove node_modules folder and run npm install

Try 3

npm rebuild node-sass

Try 4

npm install --save node-sass

For your ref you can go through this github link



回答4:

I tried both

npm rebuild node-sass

and

npm install --save node-sass

Later by seeing EACCESS, i checked the folder permission of /node_modules, which was not 777 permission

Then I gave

chmod -R 777 *

-R for recursively(setting the same permission not in the dir but also inside nested sub dir) * is for all files in current directory

What is file permission

To check for permission you can use

ls -l

If u don't know about it, first see here, then check the url

Every file and directory has permission of 'rwx'(read, write, execute). and if 'x' permission is not there, then you can not execture, if no 'w', you can not write into the file. if some thing is missiing it will show in place of r/w/x with '-'. So, if 'x' permission is not there, it will show like 'rw-'

And there will be 3 category of user Owner(who created the file/directory), Group(some people who shares same permission and user previlege), Others(general public)

So 1st letter is 'd'(if it is a directory) or '-'(if it is not a directory), followed by rwx for owner, followed by for group, followed by other

drwxrwxrwx

For example, for 'node_modules'directory I want to give permission to owner all permission and for rest only read, then it will be

drwxr--r--

And about the number assume for 'r/w/x' it is 1 and for '-' it is 0, 777, first 7 is for owner, followed by group, followed by other

Let's assume the permission is rwxr-xrw-

Now 'rwx' is like '111' and it's equivalent decimal is 1*2^2+1*2^1+1*2^0=7

Now 'r-x' is like '101' and it's equivalent decimal is 1*2^2+0*2^1+1*2^0=5

Now 'rw-' is like '110' and it's equivalent decimal is 1*2^2+1*2^1+0*2^0=6

So, it will be 756



回答5:

Laravel Mix 4 switches from node-sass to dart-sass (which may not compile as you would expect, OR you have to deal with the issues one by one)

OR

npm install node-sass


mix.sass('resources/sass/app.sass', 'public/css', {
implementation: require('node-sass')
});

https://laravel-mix.com/docs/4.0/upgrade



回答6:

you have to update your node.js and angular/cli.If you update these two things then your project has angular.json file instead of angular-cli.json file.Then add css file into angular.json file.If you add css file into angular-cli.json file instead of angular.json file,then errors are occured.



回答7:

Try to run

npm i node-sass@latest