无法将 MERN 应用程序部署到 Heroku:构建失败

时间:2021-07-05 18:45:41

标签: docker heroku dockerfile web-deployment mern

我创建了一个简单的 MERN 堆栈应用程序并尝试在 heroku 上部署该应用程序,但是,构建失败并出现以下错误:

    === Pushing Procfile web (Dockerfile)
Error parsing reference: "registry.heroku.com/mydocker-libmern/Procfile web" is not a valid repository/tag: invalid reference format: repository name must be lowercase
=!= Build failed due to an error:
=!= push step: exit status 1

我只是在学习 MERN stack 和 heroku,所以我无法找出我的错误。这是我的 heroku 构建日志:

=== Fetching app code
=== Building Procfile web (Dockerfile)
Sending build context to Docker daemon  1.066MBStep 1/8 : FROM node:8
8: Pulling from library/node
146bd6a88618: Pulling fs layer
9935d0c62ace: Pulling fs layer
db0efb86e806: Pulling fs layer
e705a4c4fd31: Pulling fs layer
c877b722db6f: Pulling fs layer
645c20ec8214: Pulling fs layer
db8fbd9db2fe: Pulling fs layer
1c151cd1b3ea: Pulling fs layer
fbd993995f40: Pulling fs layer
e705a4c4fd31: Waiting
c877b722db6f: Waiting
645c20ec8214: Waiting
db8fbd9db2fe: Waiting
1c151cd1b3ea: Waiting
fbd993995f40: Waiting
db0efb86e806: Verifying Checksum
db0efb86e806: Download complete
9935d0c62ace: Verifying Checksum
9935d0c62ace: Download complete
146bd6a88618: Verifying Checksum
146bd6a88618: Download complete
e705a4c4fd31: Verifying Checksum
e705a4c4fd31: Download complete
645c20ec8214: Verifying Checksum
645c20ec8214: Download complete
db8fbd9db2fe: Verifying Checksum
db8fbd9db2fe: Download complete
1c151cd1b3ea: Verifying Checksum
1c151cd1b3ea: Download complete
fbd993995f40: Verifying Checksum
fbd993995f40: Download complete
c877b722db6f: Verifying Checksum
c877b722db6f: Download complete
146bd6a88618: Pull complete
9935d0c62ace: Pull complete
db0efb86e806: Pull complete
e705a4c4fd31: Pull complete
c877b722db6f: Pull complete
645c20ec8214: Pull complete
db8fbd9db2fe: Pull complete
1c151cd1b3ea: Pull complete
fbd993995f40: Pull complete
Digest: sha256:a681bf74805b80d03eb21a6c0ef168a976108a287a74167ab593fc953aac34df
Status: Downloaded newer image for node:8
 ---> 8eeadf3757f4
Step 2/8 : WORKDIR /app
 ---> Running in 6f59d3ab046e
Removing intermediate container 6f59d3ab046e
 ---> e6d2820f875b
Step 3/8 : COPY package*.json ./
 ---> d01a3c849dce
Step 4/8 : RUN npm install
 ---> Running in 1dd479505c5c
npm WARN read-shrinkwrap This version of npm is compatible with lockfileVersion@1, but package-lock.json was generated for lockfileVersion@2. I'll try to do my best with it!
> core-js@2.6.12 postinstall /app/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"
Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!
The project needs your help! Please consider supporting of core-js on Open Collective or Patreon: 
> https://opencollective.com/core-js 
> https://www.patreon.com/zloirock 
Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)
> uglifyjs-webpack-plugin@0.4.6 postinstall /app/node_modules/uglifyjs-webpack-plugin
> node lib/post_install.js
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.2 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/watchpack-chokidar2/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.3.2 (node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
added 1396 packages from 871 contributors and audited 1442 packages in 27.455s
46 packages are looking for funding
  run `npm fund` for details
found 92 vulnerabilities (34 low, 49 moderate, 9 high)
  run `npm audit fix` to fix them, or `npm audit` for details
Removing intermediate container 1dd479505c5c
 ---> ba95593912de
Step 5/8 : COPY . .
 ---> 92c0f6644d22
Step 6/8 : RUN npm run build
 ---> Running in bdb8ab31ef1b
> mern-crud@0.1.0 build /app
> react-scripts build
Creating an optimized production build...
Compiled with warnings.
./src/App.js
  Line 2:  'ReactDOM' is defined but never used  no-unused-vars
./src/registerServiceWorker.js
  Line 45:  Unnecessary escape character: \/  no-useless-escape
  Line 45:  Unnecessary escape character: \/  no-useless-escape
./src/components/Create.js
  Line 2:  'ReactDOM' is defined but never used  no-unused-vars
./src/components/Home.js
  Line 2:  'axios' is defined but never used  no-unused-vars
  Line 3:  'Link' is defined but never used   no-unused-vars
./src/components/Navbar.js
  Line 2:  'axios' is defined but never used  no-unused-vars
  Line 3:  'Link' is defined but never used   no-unused-vars
./src/components/Footer.js
  Line 2:  'axios' is defined but never used  no-unused-vars
  Line 3:  'Link' is defined but never used   no-unused-vars
Search for the keywords to learn more about each warning.
To ignore, add // eslint-disable-next-line to the line before.
File sizes after gzip:
  61.88 KB  build/static/js/main.4d143893.js
  32.28 KB  build/static/css/main.8308ed42.css
The project was built assuming it is hosted at the server root.
To override this, specify the homepage in your package.json.
For example, add this to build it for GitHub Pages:
  "homepage" : "http://myname.github.io/myapp",
The build folder is ready to be deployed.
You may serve it with a static server:
  npm install -g serve
  serve -s build
Removing intermediate container bdb8ab31ef1b
 ---> c5891dfadf15
Step 7/8 : EXPOSE 3000
 ---> Running in c5735fbc9972
Removing intermediate container c5735fbc9972
 ---> f40475140a26
Step 8/8 : CMD [ "npm", "start" ]
 ---> Running in 8f6660ab0250
Removing intermediate container 8f6660ab0250
 ---> f182f7d5b6a3
Successfully built f182f7d5b6a3
Successfully tagged 34e979fa4038fc1b151eb3428263d5ef353362b6:latest
=== Pushing Procfile web (Dockerfile)
Error parsing reference: "registry.heroku.com/mydocker-libmern/Procfile web" is not a valid repository/tag: invalid reference format: repository name must be lowercase
=!= Build failed due to an error:
=!= push step: exit status 1
If this persists, please contact us at https://help.heroku.com/.

这是我的源代码:https://github.com/SreyaSalil/mern-lib-crud

由于我仍在学习 MERN 和 heroku,如果您能详细解释我做错了什么以及如何更正,那就太好了。

1 个答案:

答案 0 :(得分:1)

将您的 heroku.yml (here) 文件更改为

build:
  docker:
    web: Dockerfile

请勿直接复制粘贴(可能会导致缩进问题)。