javascript - Heroku 构建失败 [sh: 1: react-scripts: Permission denied]
问题描述
----> Node.js app detected
-----> Creating runtime environment
NPM_CONFIG_LOGLEVEL=error
NODE_ENV=production
NODE_MODULES_CACHE=true
NODE_VERBOSE=false
-----> Installing binaries
engines.node (package.json): unspecified
engines.npm (package.json): unspecified (use default)
Resolving node version 12.x...
Downloading and installing node 12.13.0...
Using default npm version: 6.12.0
-----> Installing dependencies
Prebuild detected (node_modules already exists)
Rebuilding any native modules
> nodemon@1.19.3 postinstall /tmp/build_33db88ab97938128199a401d17366aac/node_modules/nodemon
> node bin/postinstall || exit 0
Love nodemon? You can now support the project via the open collective:
> https://opencollective.com/nodemon/donate
//REMOVED INSTALLATION TEXT HERE DUE TO CHAR LIMIT
-----> Build
Running heroku-postbuild
> website_setup@1.0.0 heroku-postbuild /tmp/build_33db88ab97938128199a401d17366aac
> NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client
audited 905041 packages in 14.447s
found 1 moderate severity vulnerability
run `npm audit fix` to fix them, or `npm audit` for details
> client@0.1.0 build /tmp/build_33db88ab97938128199a401d17366aac/client
> react-scripts build
sh: 1: react-scripts: Permission denied
npm ERR! code ELIFECYCLE
npm ERR! errno 126
npm ERR! client@0.1.0 build: `react-scripts build`
npm ERR! Exit status 126
npm ERR!
npm ERR! Failed at the client@0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /tmp/npmcache.1egfD/_logs/2019-11-08T01_04_59_454Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 126
npm ERR! website_setup@1.0.0 heroku-postbuild: `NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client`
npm ERR! Exit status 126
npm ERR!
npm ERR! Failed at the website_setup@1.0.0 heroku-postbuild script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /tmp/npmcache.1egfD/_logs/2019-11-08T01_04_59_470Z-debug.log
-----> Build failed
We're sorry this build is failing! You can troubleshoot common issues here:
https://devcenter.heroku.com/articles/troubleshooting-node-deploys
Some possible problems:
- node_modules checked into source control
https://blog.heroku.com/node-habits-2016#9-only-git-the-important-bits
- Node version not specified in package.json
https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version
Love,
Heroku
! Push rejected, failed to compile Node.js app.
! Push failed
概要:
我最近完成了 MERN 堆栈课程并去将我的构建推送到 Heroku,但遇到了上面的错误。我首先认为这是一个 Visual Studio 权限错误,所以我以提升的权限运行 vs 代码。然而,这并没有奏效。
我已经尝试过但没有成功:
- 将 nodejs 脚本构建包添加到我的部署中
- 修改我的 package.json 以合并引擎,该引擎选择要运行的 node.js 版本
- 在脚本部分中将 .js 扩展添加到服务器的末尾,认为这可能是一个简单的问题
- 仔细检查我的本地实例是否正常工作(确实如此)
- 立即把我的电脑扔出窗外(感觉还不错,但还是不行)
请参阅此链接以查看如何检查文件的正确权限以及如何设置它们(在 Windows 7 上使用 git-bash 更新文件权限)
解决方案
sh: 1: react-scripts: Permission denied
所以这是一个权限问题。转到包含 a 的正确路径react-scripts
并执行 achmod +x react-scripts
将解决此问题。
推荐阅读
- javascript - Phaser 2.8.1 如何从屏幕的任意位置拖动精灵?
- mysql - 表中的 MySQL 复杂连接
- .net - Outlook中的ActivateTab如何
- javascript - Laravel flash 消息无法使用关闭按钮关闭,并且在一段时间内无法自行关闭
- apache - mod_rewrite 参数作为目录并维护相对 url
- docker - 是否可以将公共 docker 镜像存储在私有 docker 注册表中
- spring-boot - Spring-Boot Embedded Tomcat - 生成 localhost.log 和 cataline.out 文件
- python - 如何将熊猫数据帧逐行写入CSV文件,一次一行?
- python - 如何在 Ubuntu 18.04 中将 pip3 更新到其最新版本?
- css - 每个引导导航栏链接可以单独间隔吗