node.js - npm install express-generator -g 错误:EACCES:权限被拒绝,访问“/usr/lib/node_modules”
问题描述
我正在关注 Mozila 网站上的 Express 教程。我做了以下事情:
我安装了 Node-js
我使用命令创建了一个导演“Express_tutorial”
mkdir express_tutorial
并在其中导航cd Express_tutorial
我在里面执行了命令
npm init
,并将他们询问的每个查询都保留为默认值。然后我尝试
npm install express
在 package.json 文件中得到一个明确的依赖关系。然后我尝试了
npm install express-generator -g
然后我得到以下信息:
npm install express-generator -g
npm WARN deprecated mkdirp@0.5.1: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)
npm WARN checkPermissions Missing write access to /usr/lib/node_modules
npm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /usr/lib/node_modules
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, access '/usr/lib/node_modules'
npm ERR! [Error: EACCES: permission denied, access '/usr/lib/node_modules'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/usr/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! /home/pc/.npm/_logs/2021-05-10T11_25_42_963Z-debug.log
解决方案
推荐阅读
- node.js - 有没有其他方法可以在给定时间后删除猫鼬中的数据
- c++ - 如何使用椭圆方程绘制椭圆?
- julia - 索引 Julia DataFrame 时感叹号的含义是什么?
- tkinter - tkinter 中的多处理未在 output_box 中获得文本输出
- html - 如何在表格中使用 HTML 单词对齐
- algorithm - 如何快速判断两个双组相交与否?
- c# - 如何将 Panel 的单个实例多次添加到单个 FlowLayoutPanel(C# 桌面应用程序)?
- android - 如何在 Android 中制作自定义 DialogFragment?
- google-apps-script - Google 表格可以添加 API 密钥访问权限吗?
- vbscript - 替换txt文件中的文本函数值输入不起作用