繁体   English   中英

Node js 应用程序的 Azure 部署失败:npm ERR! 代码 EPERM

[英]Azure deployment fails for Node js application : npm ERR! code EPERM

我正在尝试在 Azure 应用服务上部署节点 js 应用程序。 应用程序文件和 node_modules 文件夹按预期创建,但应用程序无法启动并出现以下错误

 2021-02-10T04:22:12.727825432Z npm ERR! code EPERM
2021-02-10T04:22:12.734836329Z npm ERR! syscall lchown
2021-02-10T04:22:12.734870329Z npm ERR! path /home/site/wwwroot/node_modules/istanbul-lib-instrument/node_modules/.bin/semver
2021-02-10T04:22:12.754015919Z npm ERR! errno -1
2021-02-10T04:22:12.754037719Z npm ERR! Error: EPERM: operation not permitted, lchown '/home/site/wwwroot/node_modules/istanbul-lib-instrument/node_modules/.bin/semver'
2021-02-10T04:22:12.754053319Z npm ERR!  [OperationalError: EPERM: operation not permitted, lchown '/home/site/wwwroot/node_modules/istanbul-lib-instrument/node_modules/.bin/semver'] {
2021-02-10T04:22:12.754058419Z npm ERR!   cause: [Error: EPERM: operation not permitted, lchown '/home/site/wwwroot/node_modules/istanbul-lib-instrument/node_modules/.bin/semver'] {
2021-02-10T04:22:12.754062319Z npm ERR!     errno: -1,
2021-02-10T04:22:12.754065719Z npm ERR!     code: 'EPERM',
2021-02-10T04:22:12.754069319Z npm ERR!     syscall: 'lchown',
2021-02-10T04:22:12.754073019Z npm ERR!     path: '/home/site/wwwroot/node_modules/istanbul-lib-instrument/node_modules/.bin/semver'
2021-02-10T04:22:12.754076719Z npm ERR!   },
2021-02-10T04:22:12.754097119Z npm ERR!   errno: -1,
2021-02-10T04:22:12.754100719Z npm ERR!   code: 'EPERM',
2021-02-10T04:22:12.754104319Z npm ERR!   syscall: 'lchown',
2021-02-10T04:22:12.754107819Z npm ERR!   path: '/home/site/wwwroot/node_modules/istanbul-lib-instrument/node_modules/.bin/semver',
2021-02-10T04:22:12.754111519Z npm ERR!   parent: 'istanbul-lib-instrument'
2021-02-10T04:22:12.758140417Z npm ERR! }
2021-02-10T04:22:12.761503315Z npm ERR! 
2021-02-10T04:22:12.762563214Z npm ERR! The operation was rejected by your operating system.
2021-02-10T04:22:12.763983914Z npm ERR! It is likely you do not have the permissions to access this file as the current user
2021-02-10T04:22:12.764467213Z npm ERR! 
2021-02-10T04:22:12.765574713Z npm ERR! If you believe this might be a permissions issue, please double-check the
2021-02-10T04:22:12.769113211Z npm ERR! permissions of the file and its containing directories, or try running
2021-02-10T04:22:12.769133011Z npm ERR! the command again as root/Administrator.

它是基于 Linux 的应用服务。 启动命令 - npm install && npm start

节点版本 12. NPM - 6.14

该应用程序在第一次部署时工作,但在所有进一步的部署中都失败了

我被困在这两天了。 提前致谢

Node js 应用程序的 Azure 部署失败:npm ERR! 代码 EPERM

您可以尝试通过命令行清理 npm 缓存:

npm cache clean --force

如果它不适合您,请手动删除缓存文件。 为此,将 go 复制到默认的 NPM 缓存文件夹并删除其内容:

默认值:linux 上的~/.npmWindow 上的%AppData%/npm-cache

然后您可以尝试安装并启动您的应用程序。

笔记:

避免使用sudo npm install -g因为你可能会弄乱 npm 权限。 而是将权限更改为 npm 的默认目录,或者将 npm 的默认目录更改为另一个目录。 此处的更多详细信息: https://docs.npmjs.com/getting-started/fixing-npm-permissions

我能够通过两种方式解决这个问题。

  1. 在管道中构建后,是否安装了 NPM 以包含 node_modules 文件夹并进行部署。 npm start at the app service start 命令运行应用程序。

  2. 按照这个链接使用 Doris 建议的链接,一切正常。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM