【问题标题】:Install issues with Strapi on Ubuntu 18.04 using npm使用 npm 在 Ubuntu 18.04 上安装 Strapi 问题
【发布时间】:2019-09-19 02:04:42
【问题描述】:

环境

我正在尝试使用 Ubuntu 18.04 在 Google Cloud 实例上安装 Strapi。我安装了 Node 和 npm(分别为 10.16.3 和 6.9.0)。我在执行 npm install 命令后遇到错误消息。

快速入门不起作用

我曾尝试使用快速入门指南中的$ npx create-strapi-app my-project --quickstart 选项,但这只是挂在Installing dependencies: flatten@1.0.2: I wrote this module a very long time ago; you should use something else.

错误

这是我在命令行中输入的安装 Strapi 的内容:

$ npm install strapi@beta -g

以下是结果错误:

npm WARN deprecated boom@7.3.0: This module has moved and is now available at @hapi/boom. Please update your dependencies as this version is no longer maintained an may contain bugs and security issues. 
npm WARN deprecated hoek@6.1.3: This module has moved and is now available at @hapi/hoek. Please update your dependencies as this version is no longer maintained an may contain bugs and security issues. 
npm WARN checkPermissions Missing write access to /usr/lib/node_modules.
npm ERR! path /usr/lib/node_modules.
npm ERR! code EACCES 
npm ERR! errno -13 
npm ERR! syscall access 
npm ERR! Error: EACCES: permission denied, access '/usr/lib/node_modules' 
npm ERR!  { [Error: EACCES: permission denied, access'/usr/lib/node_modules'] 
npm ERR!   stack: 
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! 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/justme/.npm/_logs/2019-09-19T01_52_40_382Z-debug.log

一些警告和一些 npm ERR!s 看起来像是权限问题,但始终被建议不要以 root/sudo 身份运行

我的预期......

为了能够进步到$ strapi new my-project

【问题讨论】:

    标签: npm strapi


    【解决方案1】:

    您要么以 root 身份运行,要么使用 sudo

    npm ERR! code EACCES

    这不是 Strapi 问题,您永远不应该以 root 用户身份使用 npm 或使用 sudo。

    https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally

    https://medium.com/@ExplosionPills/dont-use-sudo-with-npm-still-66e609f5f92

    【讨论】:

    • 该命令不是由 root 或使用 sudo 权限运行的。用户是 myname(不是 root),命令是 $ npm install strapi@beta -g
    • 权限问题好像是npm默认目录。按照@derrek-mehaffy 答案中第一个链接上有关如何更改默认目录的指南解决了 EACCES 问题,但不幸的是,我仍然在Installing dependencies: flatten@1.0.2: I wrote this module a very long time ago; you should use something else. 上挂起,这个过程永远不会过去。
    猜你喜欢
    • 2019-05-03
    • 1970-01-01
    • 1970-01-01
    • 2019-11-11
    • 2019-02-16
    • 1970-01-01
    • 1970-01-01
    • 2020-06-26
    • 1970-01-01
    相关资源
    最近更新 更多