Ошибка сборки модуля VueJs: Ошибка: не удалось найти предустановку "@ vue / app" относительно каталога - PullRequest
0 голосов
/ 06 декабря 2018

Я использую vue-tour в своем приложении, проблема в том, что когда я импортировал библиотеку, мое приложение больше не работает, это ошибка, когда я пытаюсь выполнить команду npm run dev:

 error  in ./~/vue-tour/dist/vue-tour.umd.js

Module build failed: Error: Couldn't find preset "@vue/app" relative to directory "C:\\xampp\\htdocs\\avanttia\\node_modules\\vue-tour"
    at C:\xampp\htdocs\avanttia\node_modules\babel-core\lib\transformation\file\options\option-manager.js:293:19
    at Array.map (<anonymous>)
    at OptionManager.resolvePresets (C:\xampp\htdocs\avanttia\node_modules\babel-core\lib\transformation\file\options\option-manager.js:275:20)
    at OptionManager.mergePresets (C:\xampp\htdocs\avanttia\node_modules\babel-core\lib\transformation\file\options\option-manager.js:264:10)
    at OptionManager.mergeOptions (C:\xampp\htdocs\avanttia\node_modules\babel-core\lib\transformation\file\options\option-manager.js:249:14)
    at OptionManager.init (C:\xampp\htdocs\avanttia\node_modules\babel-core\lib\transformation\file\options\option-manager.js:368:12)
    at File.initOptions (C:\xampp\htdocs\avanttia\node_modules\babel-core\lib\transformation\file\index.js:212:65)
    at new File (C:\xampp\htdocs\avanttia\node_modules\babel-core\lib\transformation\file\index.js:135:24)
    at Pipeline.transform (C:\xampp\htdocs\avanttia\node_modules\babel-core\lib\transformation\pipeline.js:46:16)
    at transpile (C:\xampp\htdocs\avanttia\node_modules\babel-loader\lib\index.js:46:20)
    at Object.module.exports (C:\xampp\htdocs\avanttia\node_modules\babel-loader\lib\index.js:163:20)

 @ ./resources/assets/js/wizard/main.js 49:15-34
 @ multi ./resources/assets/js/wizard/main.js

Импорт библиотеки следующим образом:

import '@/bootstrap'

import VueDragDrop from 'vue-drag-drop'
import VueTour from 'vue-tour'

import Wizard from '@/wizard/containers/Wizard.vue'

require('/node_modules/vue-tour/dist/vue-tour.css')

const Vue = window.Vue

Vue.use(VueTour)
Vue.use(VueDragDrop)

const vm = new Vue({
  el: '#wizard-app',
  render: h => h(Wizard)
})

export default vm

Редактировать: Это файл конфигурации mi .babelrc:

{
  "presets": [
    [ "env", {
      "targets": {
        "uglify": true,
        "node": "current"
      },
      "modules": false,
      "loose": true,
      "useBuiltIns": true,
      "debug": true,
    }]
  ],
  "plugins": [
    ["component", [{
      "libraryName": "element-ui",
      "styleLibraryName": "theme-chalk"
    }]],
    ["module-resolver", {
      "alias": {
        "@": "./resources/assets/js"
      }
    }],
    ["transform-es2015-template-literals", {
      "loose": true,
      "spec": true
    }]

  ],

}

и файл конфигурации .babelrc изБиблиотека vue-tour:

{
  "presets": [
    "@vue/app"
  ]
}

Почему vue не может найти @ vue / app ?, похоже, что существует конфликт в свойстве alias, но я понятия не имею, как изменить, не нарушив конфигурацию проекта.

обновление: если в библиотеке node_modules / vue-tour я изменяю файл .babalrc следующим образом:

"presets": [
        "es2015"
      ]

он работает, как и ожидалось, но этонежелательно, так как я должен измениться везде, где мне нужно развернуть этот проект.

1 Ответ

0 голосов
/ 09 января 2019

После нескольких дней борьбы с этой проблемой, я наконец нашел решение для этого:

В webpack.mix.js преобразование es2015 было сделано так:

  {
        test: /\.js$/,
        exclude: /node_modules\/(?!(some-library)\/).*/,
        include: [/node_modules\/vue-tour/], // <---Added this line!
        use: {
          loader: 'babel-loader',
          options: {
            presets: ['env']
          }
        }
      }
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...