por favor ayúdenme me gustaría saber por qué no funciona o si lo estoy haciendo mal.
I npm i mathlive para obtener información. Y seguir la implementación de los complementos nuxt en la documentación no funciona.
nuxt.config.js
export default { // Global page headers: https://go.nuxtjs.dev/config-head head: { title: 'Nuxtnumer', htmlAttrs: { lang: 'en', }, meta: [ { charset: 'utf-8' }, { name: 'viewport', content: 'width=device-width, initial-scale=1' }, { hid: 'description', name: 'description', content: '' }, { name: 'format-detection', content: 'telephone=no' }, ], link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }], }, // Global CSS: https://go.nuxtjs.dev/config-css css: [], // Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins plugins: ['./plugins/mathlive-vue.js'], // Auto import components: https://go.nuxtjs.dev/config-components components: true, // Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules buildModules: [], // Modules: https://go.nuxtjs.dev/config-modules modules: [ // https://go.nuxtjs.dev/bootstrap 'bootstrap-vue/nuxt', // https://go.nuxtjs.dev/axios '@nuxtjs/axios', ], // Axios module configuration: https://go.nuxtjs.dev/config-axios axios: { // Workaround to avoid enforcing hard-coded localhost:3000: https://github.com/nuxt-community/axios-module/issues/308 baseURL: '/', }, // Build Configuration: https://go.nuxtjs.dev/config-build build: { transpile: ['mathlive-vue'] }, }archivo mathlive-vue.js en complementos de directorio
import Vue from 'vue'; import * as Mathlive from 'mathlive'; import Mathfield from 'mathlive/dist/vue-mathlive.mjs' Vue.use(Mathlive,Mathfield)Error:
ERROR Error al compilar con 1 errores errores amistosos 19:26:11
ERROR en ./node_modules/mathlive/dist/vue-mathlive.mjs errores amistosos 19:26:11
El análisis del módulo falló: Token inesperado (2:342) errores amistosos 19:26:11
Es posible que necesite un cargador apropiado para manejar este tipo de archivo, actualmente no hay cargadores configurados para procesar este archivo. Consulte https://webpack.js.org/concepts#loaders | /** MathLive 0.69.11 */
No he usado Mathlive específicamente, pero leí tu pregunta y sospeché que:
transpile: ['mathlive-vue']Debiera ser:
transpile: ['vue-mathlive']porque la salida se queja de ./node_modules/mathlive/dist/vue-mathlive.mjs específicamente.
Hice girar una aplicación rápida y pude recrear su error copiando su configuración de transpile. Cambiar a vue-mathline resolvió el error por mí.
En caso de que usted (o cualquier otra persona que encuentre esta pregunta) se pregunte qué está pasando, el código de Mathlive usa módulos ES, que no se pueden ejecutar en Node (el lado del servidor de su aplicación Nuxt). Por lo tanto, debe informar a Nuxt que esos archivos deben transpilarse (hacerse compatibles con el nodo) para que funcionen.