Build errors, cannot found any of modules

Hi,

I have an application that I’ve been working on and have gotten to the point I want to deploy it somewhere rather than running it locally.

Locally, this runs fine vue-cli-service serve however, when I run vue-cli-service build I get build errors saying that it can’t find modules, basically every import to my own modules fails, for example…

<script lang="ts">
    import {Component, Vue} from 'vue-property-decorator';
    import MarketOpeningTimeBadge from "@/components/MarketOpeningTimeBadge";

    @Component({
        components: {MarketOpeningTimeBadge}
    })
    export default class MarketOpeningTimes extends Vue {

    }
</script>

Example Error…

 error  in C:/projects/Research and Development/daleellis/sentiment-investment/client/src/components/MarketOpeningTimes.vue

ERROR in C:/projects/Research and Development/daleellis/sentiment-investment/client/src/components/MarketOpeningTimes.vue
12:36 Cannot find module '@/components/MarketOpeningTimeBadge'.
    10 | <script lang="ts">
    11 |     import {Component, Vue} from 'vue-property-decorator';
  > 12 |     import MarketOpeningTimeBadge from "@/components/MarketOpeningTimeBadge";
       |                                    ^
    13 | 
    14 |     @Component({
    15 |         components: {MarketOpeningTimeBadge}

There are no issues when I run serve locally in regards to the application working, but I notice that also displays the errors in the console.

What do I need to do to resolve the build?

Thanks

"vue": "^2.6.10",
"vue-class-component": "^7.0.2",
"vue-property-decorator": "^8.1.0",
"vue-router": "^3.0.3",
"vue-socket.io": "^3.0.7",
"vuetify": "^1.5.5",
"vuex": "^3.0.1",
"vuex-class": "^0.3.2"

Try,

$ npm run build

to create your dist directory.

Hi Shane,

Unfortunately, that is exactly how I am executing the vue-cli-service build command, by running…

$ npm run build

I’m a bit guessing here, but it could be tht Typescript wants to see the file extensions?

so try adding .vue to the imports of vue files:

import MarketOpeningTimeBadge from "@/components/MarketOpeningTimeBadge.vue";

It doesn’t really make sense as it works with npm run serve (as far as I understand you) but who knows. Don’t know your project config etc.

Thanks that has done the trick adding .vue