我有一个结构如下的项目:
root
| package.json
|
|___server
| server.ts
| tsconfig.json
|
|___client
| babel.config.json
| vue.config.js
| tsconfig.json
|
|___src
main.ts
我在项目的根目录下有一个package.json,它同时运行客户端和服务器build / test / lint / serve。服务器似乎正常工作,但是当我使用vue-cli-service为客户端运行构建/服务时,出现以下错误:
未找到此相对模块:
* ./src/main.js在多个./src/main.js中
我已经尝试了一些修复程序:
到目前为止,我一直未能成功解决此问题。我该怎么办才能解决此错误?
{
"main": "dist/server/server.js",
"types": "dist/server/index.d.ts",
"scripts": {
"build": "rimraf dist && tsc --p server/tsconfig.json && cd client && vue-cli-service build",
"build-client": "rimraf dist/client && cd client && vue-cli-service build",
"build-server": "rimraf dist/server && tsc --p server/tsconfig.json",
"serve:local": "concurrently \"npm run serve-server:local\" \"npm run serve-client:local\"",
"serve-server:local": "npm run build-server && env NODE_ENV=local node dist/server/server.js",
"serve-client:local": "cd client && vue-cli-service serve --mode local"
}
}
module.exports = {
transpileDependencies: ['vuetify'],
devServer: {
proxy: 'http://localhost:3000',
},
configureWebpack: {
devtool: 'source-map',
}
};
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"strict": true,
"jsx": "preserve",
"importHelpers": true,
"moduleResolution": "node",
"experimentalDecorators": true,
"allowJs": true,
"outDir": "../dist/client",
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"baseUrl": ".",
"types": [
"webpack-env",
"vuetify",
"jest"
],
"paths": {
"@/*": [
"src/*"
]
},
"lib": [
"esnext",
"dom",
"dom.iterable",
"scripthost"
]
},
"include": [
"src/**/*.ts",
"src/**/*.tsx",
"src/**/*.vue",
"tests/**/*.ts",
"tests/**/*.tsx"
],
"exclude": [
"node_modules"
]
}
import Vue, { VNode } from 'vue';
import App from './App.vue';
import vuetify from './plugins/vuetify';
import router from './router';
import store from './store';
Vue.config.productionTip = false;
new Vue({
vuetify,
router,
store,
render: (h): VNode => h(App),
}).$mount('#app');