Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vue.js Npm运行构建生成错误路径_Vue.js_Npm_Vue Cli 3 - Fatal编程技术网

Vue.js Npm运行构建生成错误路径

Vue.js Npm运行构建生成错误路径,vue.js,npm,vue-cli-3,Vue.js,Npm,Vue Cli 3,要部署我的Vue Cli 3项目,我确实执行了npm运行build,但是新dist/文件夹中的index.html包含如下错误路径: <link href=/css/app.35dee36a.css <link href=/js/app.826dde09.js 它应该是http://my_site.com/timelog/js,而不是http://my_site.com/js 我试图在package.json中通过添加“baseUrl”来指定URL:http://my_site.c

要部署我的
Vue Cli 3
项目,我确实执行了
npm运行build
,但是新
dist/
文件夹中的
index.html
包含如下错误路径:

<link href=/css/app.35dee36a.css
<link href=/js/app.826dde09.js
它应该是
http://my_site.com/timelog/js
,而不是
http://my_site.com/js

我试图在
package.json
中通过添加
“baseUrl”来指定URL:http://my_site.com/timelog/,“主页”:http://my_site.com/timelog/“,
但它不会改变任何东西


导致此问题的原因以及解决方法?

我通过在项目根目录下创建一个包含以下内容的
vue.config.js
文件来解决此问题:

module.exports = {
  baseUrl: '/timelog/'
}

(为了使内部链接也能正常工作,请参见)

构建的版本应该在具有实际域名的Web服务器上运行。我有一个便宜的共享主机包,我认为我不能在他们的服务器上运行类似的东西。您确定这就是问题所在,并且没有解决方法吗?如果您想开发,请运行
npm run serve
,然后转到
localhost:8080
或运行它的任何端口
npm运行版本
是一个生产版本,如果通过
文件://
链接打开
index.html
,则该版本不起作用。只要您对服务器具有ftp或sftp访问权限,并且拥有任何域名,您就应该能够将
dist
文件夹中的任何内容传输到作为公用html文件夹的文件夹中。这将允许您访问
yourdomain.com/index.html
yourdomain.com
(如果启用了任何重写)。谢谢,您是正确的,但是路径仍然错误。我编辑了这个问题。似乎
baseUrl
已被
publicPath
取代。这个答案对我有帮助,谢谢。
module.exports = {
  baseUrl: '/timelog/'
}