我使用Nuxt,有时,当我想使用一些npm包时,我会遇到这样的错误:
SyntaxError
Unexpected token '<'堆栈:
vm.js:102:7
new Script
internal/modules/cjs/loader.js:1114:10
Module._extensions..js
internal/modules/cjs/loader.js:950:32
Module.load
internal/modules/cjs/loader.js:790:14
Module._load
internal/modules/cjs/loader.js:974:19
Module.require
webpack:/external "vue-typeahead-bootstrap":1:
Object.vue-typeahead-bootstrap
webpack/bootstrap:25:
__webpack_require__
pages/account/tabs/addresses.js:693:81
Module../node_modules/babel-loader/lib/index.js?!./node_modules/vue-loader/lib/index.js?!./components/address/form/country.vue?vue&type=script&lang=js&
webpack/bootstrap:25:例如,我在这个包上有这个错误:vue-typeahead-bootstrap
如果我导入包:
import VueTypeaheadBootstrap from ['vue-typeahead-bootstrap'](https://github.com/mattzollinhofer/vue-typeahead-bootstrap)
export default {
components: { VueTypeaheadBootstrap },
}它抛出错误。
是因为包不受支持还是什么原因?
发布于 2021-06-23 19:46:20
你可以试着转译它。https://nuxtjs.org/docs/2.x/configuration-glossary/configuration-build#transpile
添加包名,如下所示
{
build: {
transpile: [
({ isServer }) => 'vue-typeahead-bootstrap'
]
}
}在这里回答:https://github.com/mattzollinhofer/vue-typeahead-bootstrap/issues/19#issuecomment-645510809
https://stackoverflow.com/questions/68098061
复制相似问题