【发布时间】:2019-11-16 22:10:09
【问题描述】:
我是 Linux 新手,我正在尝试使用 nodejs 进行设置,但我无法弄清楚为什么我无法安装 react。我正在按照我在网上看到的指示进行操作,但我想知道为什么我似乎没有安装 react 所需的权限。这是一个个人环境,所以我没想到会有任何问题。以下是我运行的内容以及最后一行给我的最终错误。
sudo apt update && sudo apt upgrade
sudo apt install nodejs
sudo npm install npm
node -v
v8.10.0
npm -v
3.5.2
sudo npm install npm@latest -g
npm -v
6.10.0
npm install -g create-react-app
上面的一切都运行良好,直到最后一个命令。然后无论工作目录如何,我都会收到以下错误。
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! path /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
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! stack: '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! 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 (though this is not recommended).
npm ERR! A complete log of this run can be found in:
npm ERR! /home/me/.npm/_logs/2019-07-06T19_33_32_971Z-debug.log
【问题讨论】:
-
在最后一行使用
sudo。说真的。
标签: node.js linux reactjs ubuntu npm