node.js - Node js 应用程序的 Azure 部署失败:npm ERR!代码 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
如果它不适合您,请手动删除缓存文件。为此,请转到默认 NPM 缓存文件夹并删除其内容:
默认值:~/.npm
在linux上,或%AppData%/npm-cache
在 Window 上
然后您可以尝试安装并启动您的应用程序。
笔记:
避免使用sudo npm install -g
,因为您可能会弄乱 npm 权限。而是将权限更改为 npm 的默认目录,或者将 npm 的默认目录更改为另一个目录。更多详细信息:https ://docs.npmjs.com/getting-started/fixing-npm-permissions
推荐阅读
- r - R列检查是否包含来自另一列的值
- r - 如何使用 createPartition 进行分区
- c - 任何人都可以帮助我使用信号量创建死锁吗?
- php - html表单输入数字中美元和美分的模式是什么?
- python-3.x - 如何限制并行进程
- javascript - 用 js 成功扭转了过渡,但为什么我的另一种方式不起作用?
- python - 在 google colab 上的 google drive 中的视频上使用 openpose
- r - 如何生成组间成对共享矩阵并将其可视化
- javascript - 从模板中获取元素兄弟组件 ng-content
- javascript - Mongoose:使用传递选项“useUnifiedTopology:true”导致错误处理失败