作為前端攻城獅娃属,和npm打交道肯定是少不了的六荒,經(jīng)常利用npm下載各種依賴,題主就經(jīng)常遇到這個(gè)報(bào)錯(cuò)
F:\demo\webpack_study\webpack4.0>npm install webpack -D
npm ERR! path F:\demo\webpack_study\webpack4.0\node_modules\fsevents\node_modules\getpass\node_modules
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall scandir
npm ERR! Error: EPERM: operation not permitted, scandir 'F:\demo\webpack_study\webpack4.0\node_modules\fsevents\node_modules\getpass\node_modules'
npm ERR! { Error: EPERM: operation not permitted, scandir 'F:\demo\webpack_study\webpack4.0\node_modules\fsevents\node_modules\getpass\node_modules'
npm ERR! stack: 'Error: EPERM: operation not permitted, scandir \'F:\\demo\\webpack_study\\webpack4.0\\node_modules\\fsevents\\node_modules\\getpass\\node_modules\'',
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'scandir',
npm ERR! path: 'F:\\demo\\webpack_study\\webpack4.0\\node_modules\\fsevents\\node_modules\\getpass\\node_modules' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\m1701\AppData\Roaming\npm-cache\_logs\2018-02-27T08_55_31_944Z-debug.log
有時(shí)候即使出現(xiàn)了一個(gè)報(bào)錯(cuò)膳犹,但是貌似還是把依賴安裝成功了恬吕,但是有時(shí)候運(yùn)氣背,就沒成功须床。作為一個(gè)靠譜的大前端铐料,不能容忍這種不穩(wěn)定因素存在,所以樓主去查了一些資料豺旬,了解到npm有個(gè)很重要的關(guān)于緩存的指令钠惩,npm cache
npm cache verify
輸入后,npm會(huì)去校驗(yàn)一些緩存依賴的完整和有效性族阅。我估計(jì)報(bào)上述錯(cuò)誤的原因篓跛,就是因?yàn)橐螺d的依賴存在于緩存中,但是不夠完整或者有效坦刀,所以導(dǎo)致了報(bào)錯(cuò)愧沟,校驗(yàn)完成之后再下載相關(guān)的依賴就不會(huì)報(bào)這個(gè)錯(cuò)誤了。