简体   繁体   中英

npm run build cannot access in localhost

I want to test my react/ node.js web app with a production build. I already run npm run build at the app directory and created build folder.

I was unable to run the application using localhost:8080 (server port).

Are there any ways to double check if the application is actually running in that port or access production-ready application?

PS. I used serve to host the application but it posts error 404: The requested path could not be found

Thank you for your help.

Every SPA application has its own package.json file. Inside you have to see the script section: 在此处输入图片说明

Normally after you run nm run build you have a compiled version of your code. At this point, you have a see the dist folder.

After this, you can either run npm run start and you have to see在此处输入图片说明

(this option is not suitable for SSR frameworks like NUXT or NEXT) or if you don't have that option install an npm package that renders your compiled code by doing the following:

  1. npm install -g serve
  2. serve -s build and you have to see 在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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