为什么需要npm serve或Express服务器才能将create-react-app生产版本部署到heroku云服务器?

时间:2019-05-21 17:20:10

标签: reactjs heroku deployment

嗨,我想将一个create-react-app生产版本部署到Heroku服务器。     现在,我已经尝试了所有方法,但是在不使用serve npm或express服务器的情况下无法找到任何方法来部署它。     我对此有点陌生,因此请建议部署是否必须使用Express Server或npm服务器。     现在,我正在尝试通过以下方式进行部署:-

Hi have put npm run build command and get build folder now , 
In   >  .gitignor

file .

**I have added src/*
           public/*
and removed /build.**

when i tried the process suggested by heroku.
git init
heroku create -b https://github.com/mars/create-react-app-buildpack.git
git add .

git commit -m "react-create-app on Heroku"
git push heroku master


**

    Error :- 
     Could not find a required file.
    remote:          Name: index.html
    remote:          Searched in: /tmp/build_bbe41ccff2d828824411f3a41b5ae0ae/public


I received following error :-


Counting objects: 23, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (23/23), done.
Writing objects: 100% (23/23), 488.34 KiB | 0 bytes/s, done.
Total 23 (delta 0), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Node.js app detected
remote:
remote: -----> Creating runtime environment
remote:
remote:        NPM_CONFIG_LOGLEVEL=error
remote:        NODE_ENV=production
remote:        NODE_MODULES_CACHE=true
remote:        NODE_VERBOSE=false
remote:
remote: -----> Installing binaries
remote:        engines.node (package.json):  unspecified
remote:        engines.npm (package.json):   unspecified (use default)
remote:
remote:        Resolving node version 10.x...
remote:        Downloading and installing node 10.15.3...
remote:        Using default npm version: 6.4.1
remote:
remote: -----> Installing dependencies
remote:        Installing node modules (package.json + package-lock)
remote:        added 1767 packages from 770 contributors and audited 32007 packages in 36.788s
remote:        found 96 vulnerabilities (71 low, 8 moderate, 17 high)
remote:          run `npm audit fix` to fix them, or `npm audit` for details
remote:
remote: -----> Build
remote:        Running build
remote:
remote:        > client@0.1.0 build /tmp/build_bbe41ccff2d828824411f3a41b5ae0ae
remote:        > react-scripts build
remote:
remote: Browserslist: caniuse-lite is outdated. Please run next command `npm update caniuse-lite browserslist`
remote:        Could not find a required file.
remote:          Name: index.html
remote:          Searched in: /tmp/build_bbe41ccff2d828824411f3a41b5ae0ae/public
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! errno 1
remote: npm ERR! client@0.1.0 build: `react-scripts build`
remote: npm ERR! Exit status 1
remote: npm ERR! 


I have also gone through various tutorials and all about use server.js in your react app to server build file.

Now  I want to actually know that if i am doing right process or we could not deploy react production build on heroku.
You also can   suggest better way to deploy it to heroku.

0 个答案:

没有答案