B
B
BonBon Slick2020-05-12 20:31:09
typescript
BonBon Slick, 2020-05-12 20:31:09

TS2307: Cannot find module '@/../build/global_const'.?

import * as test from '@/../build/global_const'; // выдает ошибку что такого модуля нет формат файла .ts / .js
    import {Component, Vue} from "vue-property-decorator";
    import basic1 from '@/../src/components/Basic1.vue'; // находит компонент и выводит его как надо

    @Component({
        components: {
            basic1,
        },
    })
    export default class App extends Vue {

        //@todo - or use lifecycle? Стоит ли тут использовать их и почему?
        constructor() {
            super();
            console.log(test.PROD_ENV); // выводит константу
        }


webpack
module:       {
    rules: [
      {
        test:    /\.vue$/,
        loader:  'vue-loader',
        options: {
          loaders: {
       
            scss: 'vue-style-loader!css-loader!sass-loader', // <style lang="scss">
            sass: 'vue-style-loader!css-loader!sass-loader?indentedSyntax', // <style lang="sass">
          },
        },
      },
      // {
      //   test:    /\.js$/,
      //   // use:     'babel-loader',
      //   use:     'source-map-loader',
      //   exclude: /node_modules/,
      // },
      {
        test:    /\.tsx?$/,
        loader:  'ts-loader',
        exclude: /node_modules/,
        options: {
          appendTsSuffixTo: [/\.vue$/],
        },
      },


1 - why does it give an error that the module is not found?
2 - is it worth it to use lifesayls?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
BonBon Slick, 2020-05-13
@BonBonSlick

"baseUrl": ".",
    "paths": {
      "~/*": [
        "./src/*"
      ],
      "@/*": [
        "./src/*"
      ]
    }

declare module '*.vue' {
  import Vue from 'vue'
  export default Vue
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question