我的应用程序分为一个API和一个UI部分.部署策略要求他们共享一个package.json.文件 struct 看起来像

client/
       src/
           main.js
api/
package.json
vue.config.js

我使用的是标准的vue cli脚本.

package.json

"scripts": {
  "serve:ui": "vue-cli-service serve",
  "build:ui": "vue-cli-service build",
  "lint:ui": "vue-cli-service lint",
  "test:unit": "vue-cli-service test:unit"
}

当我达到npm run serve:ui分时,我得到

This relative module was not found:

* ./src/main.js in multi ./node_modules/@vue/cli-service/node_modules/webpack-dev-server/client?http://10.0.2.15:8080/sockjs-node ./node_modules/@vue/cli-service/node_modules/webpack/hot/dev-server.js ./src/main.js

所以,我试着按照docs修改vue.config.json:

vue.config.js

const path = require('path');
module.exports = {
    entry: {
        app: './client/src/main.js'
    }
}

现在,我得到了一个错误:

 ERROR  Invalid options in vue.config.js: "entry" is not allowed

How do I tell vue-cli where my app entrypoint is?

推荐答案

我发现,基于这个Github Issue,您只能在命令行中传递自定义入口点.buildserve都是如此.另见文件a single block of code demonstrating this.

Usage: vue-cli-service serve [options] [entry]

我把 playbook 改成了

    "serve:ui": "vue-cli-service serve client/src/main.js",

现在它可以找到入口点了.

Vue.js相关问答推荐

具有VUE身份验证的Azure AD

如何在与父集合相同的读取中取回子集合(或重构数据?)

使用V-TOOLTIP(实例化)使工具提示在V-文本字段中显示清晰的图标

如何使用composition api v-model Select 框获取其他JSON 值?

在预渲染模式下部署 nuxt 3 时出错

在组件之间共享 websocket 连接

vue.js 在 App.vue 中获取路由名称

Vue watch 意外调用了两次

Bootstrap-vue b-table,标题中带有过滤器

使用 vue-property-decorator 时注册本地组件

NuxtServerInit 在 Vuex 模块模式下不起作用 - Nuxt.js

Vue路由保持活动和挂载行为

使用 Vee-Validate 在提交时验证子输入组件

如何在 VueJS 中访问 [__ob__: Observer] 的元素?

Vue 如何使用 slot 和 slot-props 测试组件

如何突出显示 Vuetify 菜单中的选定项目?

Vuex:无法读取未定义的属性'$store'

vue-cli-service build --target lib 导入为 lib 时丢失图像路径

是否有 v-cloak 逆?

vue-router 如何使用 hash 推送({name:"question"})?