Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

145
Views
La función de JavaScript solo funciona en máquinas con Windows

Estoy trabajando en un proyecto en mi computadora con Windows también en mi Macbook. Obtuve una función que registra componentes definidos en ciertos directorios globalmente como este:

 require('./bootstrap'); import { createApp, h } from 'vue'; import { createInertiaApp } from '@inertiajs/inertia-vue3'; import { InertiaProgress } from '@inertiajs/progress'; /** * Third-party imports. */ import upperFirst from 'lodash/upperFirst'; import camelCase from 'lodash/camelCase'; const appName = window.document.getElementsByTagName('title')[0]?.innerText || 'Laravel'; /** * Register components from the ./components and ./components/core * directories. This way these components don't have to be imported * manually every time. * * The core components are the core of other components and contains * alerts, notifications, input fields etc. * * Base components are bigger components made upon the core components * and contain a combination of one or more of the core components. These * are usually components that contain a lot of code and have to be re-used * across the whole application. * * @param {Vue instance} app */ function registerGlobalComponents (app) { const requireComponent = require.context( './components' || './components/core' || './components/base', true, /\.vue$/ ); for (const file of requireComponent.keys()) { const componentConfig = requireComponent(file); const name = file .replace(/index.js/, '') .replace(/^\.\//, '') .replace(/\.\w+$/, ''); const componentName = upperFirst(camelCase(name)); app.component(componentName, componentConfig.default); } } createInertiaApp({ title: (title) => `${title} - ${appName}`, resolve: (name) => require(`./Pages/${name}.vue`), setup({ el, app, props, plugin }) { const inertiaApp = createApp({ render: () => h(app, props) }); inertiaApp.use(plugin); inertiaApp.mixin({ methods: { route } }) registerGlobalComponents(inertiaApp); inertiaApp.mount(el); }, }); InertiaProgress.init({ color: '#4B5563' });

Cuando ejecuto npm run watch o dev o prod , compila el código y me muestra correctamente el sitio web en mi máquina con Windows. Pero cuando hago esto en mi Macbook, arroja el siguiente error:

No se puede resolver './components' en '/Users/bas/Sites/trainfit/resources/js'

¿Hay alguna razón por la que esto funcione en una máquina con Windows pero no en una máquina que se ejecuta en MacOS?

Más información sobre mi proyecto:

  • Hecho con Vue e Inertiajs
  • Ejecutando este código desde Visual Studio Code
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Como se explica en los documentos , comienza creando un archivo jsconfig.json en su raíz con estos caracteres y símbolos:

 { "compilerOptions": { "baseUrl": "src" }, "include": ["src"] }

Puede encontrar ejemplos y referencias aquí: - aquí

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!