ionic start 創建ionic項目報錯,及解決過程
問題描述:
前一次創建利用命令行創建ionic項目一次性成功,第二次沒有運行:
$ npm install -g ionic cordova
直接運行:
ionic start ionicDemo
出現上圖錯誤:
× Running command - failed!
Exception: npm ERR! path C:\work\ionicdemo\node_modules\fsevents\node_modules
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall scandir
npm ERR! Error: EPERM: operation not permitted, scandir ‘C:\work\ionicdemo\node_modules\fsevents\node_modules‘
npm ERR! at Error (native)
npm ERR! { Error: EPERM: operation not permitted, scandir ‘C:\work\ionicdemo\node_modules\fsevents\node_modules‘
npm ERR! at Error (native)
npm ERR! stack: ‘Error: EPERM: operation not permitted, scandir \‘C:\\work\\ionicdemo\\node_modules\\fsevents\\node_modules\‘\n at Error (native)‘,
npm ERR! errno: -4048,
npm ERR! code: ‘EPERM‘,
npm ERR! syscall: ‘scandir‘,
npm ERR! path: ‘C:\\work\\ionicdemo\\node_modules\\fsevents\\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\admin\AppData\Roaming\npm-cache\_logs\2017-08-12T13_57_00_472Z-debug.log
解決辦法:
幾經折騰使用下面方法即可:
1.移除node_modules文件,然後清除npm緩存,再將npm升級,繼而重新安裝。(github 上面能夠solve那些issue的基本都是執行這些操作的,大多都是因為版本問題出現的錯誤)# rm -rf node_modules
# npm clean cache
刪除:/用戶路徑/AppData/Roaming/npm/node_modules
例如我的路徑是:C:\Users\admin\AppData\Roaming\npm\node_modules
2.重新安裝ionic CLI Cordova
# npm install -g ionic cordova
再次執行:
#ionic start ionicdemo
創建成功,OK。
ionic start 創建ionic項目報錯,及解決過程