1. 程式人生 > 其它 >Error: EACCES: permission denied, access ‘/usr/local/lib/node_modules‘

Error: EACCES: permission denied, access ‘/usr/local/lib/node_modules‘

技術標籤:日常bugvuenodemac

前言

在搭建Vue專案時報錯


報錯資訊如下:

[email protected]-Pro kang2 % npm install -g @vue/cli
npm WARN deprecated [email protected]2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated @hapi/[email protected]15.1.1: Switch to 'npm install joi'
npm WARN deprecated @hapi/[email protected]1.3.2: This version has been deprecated and is no longer supported or maintained npm WARN deprecated @hapi/[email protected]8.5.1: This version has been deprecated and is no longer supported or maintained npm WARN deprecated @hapi/[email protected]
3.1.6: This version has been deprecated and is no longer supported or maintained npm WARN deprecated @hapi/[email protected]2.1.4: Moved to 'npm install @sideway/address' npm WARN deprecated har-[email protected]5.1.5: this library is no longer supported npm WARN deprecated [email protected]
0.1.0: Please see https://github.com/lydell/urix#deprecated npm WARN deprecated resolve-[email protected]0.2.1: https://github.com/lydell/resolve-url#deprecated npm WARN deprecated [email protected]2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies. npm WARN deprecated [email protected]1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2. npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules npm WARN @vue/compiler-[email protected]3.0.4 requires a peer of [email protected]3.0.4 but none is installed. You must install peer dependencies yourself. npm ERR! code EACCES npm ERR! syscall access npm ERR! path /usr/local/lib/node_modules npm ERR! errno -13 npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules' npm ERR! [Error: EACCES: permission denied, access '/usr/local/lib/node_modules'] { npm ERR! errno: -13, npm ERR! code: 'EACCES', npm ERR! syscall: 'access', npm ERR! path: '/usr/local/lib/node_modules' npm ERR! } npm ERR! npm ERR! The operation was rejected by your operating system. npm ERR! It is likely you do not have the permissions to access this file as the current user npm ERR! npm ERR! If you believe this might be a permissions issue, please double-check the npm ERR! permissions of the file and its containing directories, or try running npm ERR! the command again as root/Administrator. npm ERR! A complete log of this run can be found in: npm ERR! /Users/cunweizhao/.npm/_logs/2020-12-10T02_55_02_028Z-debug.log

解決問題

是檔案沒有root許可權,執行語句前面加上 sudo。

在這裡插入圖片描述