Cannot run an app from vue-cli on localhost - vue.js

I installed the Vue-CLI in version 3.7. Run vue create my-project and npm run serve. Everything was fine and got message
App running at:
- Local: http://localhost:8080/
Though on the http://localhost:8080/ I got This site can’t be reached.
I managed to use vue init webpack-simple my-project and then in ./node_modules/webpack-dev-server/bin/webpack-dev-server.js change port number and with the new one it's working but this "trick" doesn't work for vue create anyway.
Node version 11.11 and OSX Mojave. There should not be anything that could block the port. I have no idea what to do with this.

please run this command in your vue project directory:-
npm run serve
OR
yarn serve
After run command refresh your browser. this command would be run repeatedly when you get 'This site can’t be reached'.

Do this:
Remove your Node.js and again install latest version here
On the installation path choose npm package manager and install
Open cmd and enter this:
npm install -g #vue/cli
After install vue cli (Previous step) enter to cmd this:
vue create name-app
After some minutes (It depends on how fast your internet is) be sure You have the correct installation
So enter in cmd this:
npm run serve
Then you should be able to navigate to localhost page http://localhost:8080

You can override webpack dev host like this:
vue.config.js
module.exports = {
devServer: {
host: '127.0.0.1',
port: 8080,
public: 'localhost:8080',
},
};
Terminal output
App running at:
Local: http://127.0.0.1:8080/
Network: http://localhost:8080/
The answer is from shenron.

Related

npm run serve on vue does not serve to localhost

I am trying to get a grasp on Vue, because frameworks, frameworks, frameworks. I installed vue with npm using npm install -g #vue/cli which worked, then i made my project folder using vue create myproj, choosing all default options. When I tried to run with npm run serve this was my output:
App running at:
- Local: http://x86_64-conda_cos6-linux-gnu:8080/
- Network: http://x86_64-conda_cos6-linux-gnu:8080/
Which doesn't connect in browser. As far as I understand, it should have localhost or 127.0.0.1 followed by the port numbers. The port is not being used by anything else. I checked my hosts:
(base) alan#skynet:~/dev/myproj$ cat /etc/hosts
127.0.0.1 localhost
127.0.1.1 skynet
I followed the steps in this similar question: https://forum.vuejs.org/t/npm-run-serve-is-not-defaulting-to-localhost/88007/13 and added a vue.config.js with the following:
module.exports = {
devServer: {
host: '127.0.0.1',
port: 8080,
public: 'localhost:8080',
}
}
but it only changed my network. I have not changed my package.json or any of the default files that come with vue create. I even deleted the directory, uninstalled and reinstalled vue in the same location and that did not resolve. This other SO thread Not running at local when "npm run serve" command in vue project was also similar, but I do not have a .bash_profile and I'm not sure if I can just throw in HOST="localhost" anywhere into my .profile file, as I'm relatively new to Linux and don't want to break things. I'm just trying to get the initial setup off the ground so I can move on to actually doing vue stuff.
I'm not sure if what I did worked, but it now works. See https://github.com/vuejs/vue-cli/issues/4081#issuecomment-694904714

Can not access localhost or 127.0.0.1 server started by vue cli webpack-dev-server

I initialized a vue project by vue/cli, and i do not change any code.After init completion, i run the command to start a development server by npm run dev.And the output show the the server running on localhost:8080, but i can not access it neither by localhost:8080 nor 127.0.0.1:8080.
I haved tried to uninstall safety software, choose vue/cli#2, check hosts file.
C:\Users\Administrator\Desktop\cl>node -v
v10.16.3
C:\Users\Administrator\Desktop\cl>npm -v
6.9.0
"webpack-dev-server": {
"version": "2.11.5",
Try npm run serve. You are not telling vue-cli-service to start a server, only to build locally.

Why after installing vue CLI through npm 6.9.0 dosn't work?

When i use this command bellow :
vue create hello-world
I got this message :
'vue' is not recognized as an internal or external command,
operable program or batch file.
After 1 month I still haven't found the solution..
Some informations:
My OS : Windows 10
NPM version : 6.9.0
vue version : 2.6.10
Vue cli installed version : #vue/cli#3.8.2
==>
0 error message when i installed all these packages.
I correctly added npm path on environement variable.
If you set the path correctly then you need to restart the system once because sometimes environment variables need restart after setting the path.
And Do this (If above not works):
Run command as administrator privileged.
npm install --global vue-cli
Set this path to environment variables:
C:\Users\YourUserName\AppData\Roaming\npm
This one too:
In last, restart the cmd, system and run the vue again. It should work just fine.

How to see the build version of a build project with npm

I know that my question gonna be quite stupid for the pro vue.js and Webpack. I'm not really use to it yet.
I have actually a little application with vue.js and webpack. I was developing and seeing the result by using the command : npm run dev
and looking at the local adress : http://localhost:8080/
Then, I have done a build version with : npm run build
So eveything is fine but now, I dont know how to see the final result locally. What I have to do or what I'm missing ?
Thank for your answer
You could use the http-server npm package:
yarn global install http-server
# Or
npm install -g http-server
then cd into your built folder and launch http-server. This should give you a url to go to.

Babel Errors in Cloud 9 IDE

Getting a bunch of babel errors when running npm run dev with the Vue cli.
This only happens in Cloud9.
Any thoughts on what could be the issue or how to disable errors like this before running npm run dev?
All babel related it looks like.
I couldn't re-create the babel error messages but it's possible that it could be caused if npm/node is not up-to-date. (Vue-cli wasn't starting dev server before the installation below)
Is your repository public where you're getting the error messages? Then I could have a look at the errors.
If removing node_modules folder is not helping,
here is how you can create a new IDE workspace for vue.js ($ for commands in bash terminal):
Create a blank Ubuntu workspace
Check that nvm is installed & up-to-date with (check version of install script here):
$ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.32.1/install.sh | bash
$ nvm install node 6
$ npm i vue-cli -g
$ vue init webpack yourAppName
$ cd yourAppName
$ npm install
$ npm run dev
Click preview to test that Vue server is running as expected
Here is a link to a HelloWorld Vue app in cloud9 ide.
If you have an existing app you can also use git to clone it into your new workspace instead of creating a new app.