Not running at local when “npm run serve” command in vue project

只愿长相守 提交于 2021-02-11 14:52:57

问题


I was trying to make some app with vue and installed npm command.

when I run "npm run serve" command, I get the following messages. It seems that I was supposed to run app at "http://localhost:8080/" and was able to access sample pages, not like "x86_64-apple-darwin13.4.0:" stuff.

is it possible to solve this with changing config file or something ?

App running at:
  - Local:   http://x86_64-apple-darwin13.4.0:8080/
  - Network: http://x86_64-apple-darwin13.4.0:8080/

  Note that the development build is not optimized.
  To create a production build, run npm run build.

I am supposed to access to http://localhost:8080/ and would get some sample pages.


回答1:


It seems like your host environment was set to x86_64-apple-darwin13.4.0, you should be able to set the variable in your bash_profile like this HOST="localhost"

after that reload the environment with source ~/.bash_profile




回答2:


Looks like you can find an answer to your question here - https://forum.vuejs.org/t/npm-run-serve-is-not-defaulting-to-localhost/88007/13.

In a short:

  • Add vue.config.js file in a root (same level as package.json file) if you don't have one

  • Add the following settings to vue.config.js

module.exports = {
  devServer: {
    host: '127.0.0.1',
    port: 8080,
    public: 'localhost:8080',
  }
}


来源:https://stackoverflow.com/questions/63242821/not-running-at-local-when-npm-run-serve-command-in-vue-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!