Netlify Vue构建无法找到导出模块

时间:2018-12-20 18:59:44

标签: javascript vue.js netlify

因此,我有几个要导入到2006-01-02T15:04:05Z07:00main.js文件中的模块,这些模块在Netlify中进行构建时找不到,我无法理解为什么。当我在本地运行构建时,没有任何问题。

所以2个文件是store.jsability.js

这是来自netlify构建的警报

storage.js

这是capability.js文件

12:48:10 PM: These relative modules were not found:
12:48:10 PM: * ./utils/ability.js in ./src/main.js, ./src/store.js
12:48:10 PM: * ./utils/storage.js in ./src/store.js
12:48:10 PM:  ERROR  Build failed with errors.

这是storage.js文件

import { Ability } from '@casl/ability'

export const ability = new Ability()

export const abilityPlugin = (store) => {
    ability.update(store.state.rules)

    const rules = store.subscribe((mutation) => {
        switch (mutation.type) {
            case 'createSession':
            ability.update(mutation.payload[0])
            break
            case 'destroySession':
            ability.update([{ actions: '', subject: '' }])
            break
        }
      })
      return rules
  }

这是我导入这些模块的2个文件

main.js

export default (options) => (store) => {
    if (localStorage.state) {
      const storedState = JSON.parse(localStorage.state)
      store.replaceState(Object.assign(store.state, storedState))
    }

    return store.subscribe((mutation, state) => {
      if (options.destroyOn && options.destroyOn.indexOf(mutation.type) !== -1) {
        return localStorage.removeItem('state')
      }

      const newState = options.storedKeys.reduce((map, key) => {
        map[key] = state[key]
        return map
      }, {})

      localStorage.state = JSON.stringify(newState)
    })
  }

store.js

import Vue from 'vue';
import App from './App.vue';
import router from './router';
import store from './store';
import { abilitiesPlugin } from '@casl/vue';
import { ability } from './utils/ability.js';

Vue.use(abilitiesPlugin, ability);

new Vue({
  router,
  store,
  render: h => h(App),
}).$mount('#app')

有问题的目录结构

enter image description here

当前有效的目录结构

enter image description here

1 个答案:

答案 0 :(得分:1)

实用程序是否在您项目的根目录中?您正在使用Vue Webpack模板吗?

如果是,则为您配置了@解析器(ES6 import using at ('@') sign in path in a vue.js project using Webpack

如果这样更改:

from './utils/ability.js'from '@/utils/storage.js'

from './utils/storage.js'from '@/utils/storage.js'