user23643630
user23643630

Reputation: 41

Vue3 project created with vue-cli not working after building

I've created a vue3 project using "vue create 'my-project'", using the default settings, and it´s ok, if I serve it, it works perfectly. When I build it, it gets done successfully but when I try to open the index.html on the browser nothing happens and I get these errors consoled:

"Failed to load resource: net::ERR_FILE_NOT_FOUNDUnderstand this error app.4a6fa159.js:1 Failed to load resource: net::ERR_FILE_NOT_FOUNDUnderstand this error app.2cf79ad6.css:1 Failed to load resource: net::ERR_FILE_NOT_FOUNDUnderstand this error /C:/favicon.ico:1 Failed to load resource: net::ERR_FILE_NOT_FOUND"`.

It makes no sense since I just created the project and built it, without any modification, so it's supposed to work.

I'm using

Upvotes: 2

Views: 135

Answers (2)

vol.qiu
vol.qiu

Reputation: 22

Because vue-cli build bundle in the html, the assets was the absolute path , but you open the index.html file directly can't visit directly

First

npm install http-server -g

Second

go to dist dir

http-server

Now visit the http://localhost:8080

Upvotes: 0

kissu
kissu

Reputation: 46774

vue create

is the wrong obsolete CLI that you should NOT be using, unfortunately.


Following the current official docs, you should be using

npm create vue@latest

Also, you still need to serve the files once built, you cannot just open the project in your browser without a server.

Upvotes: 1

Related Questions