Skip to content

Uncaught TypeError: Cannot read properties of undefined (reading 'get') #176

Closed

Description

@oliverbj

Hi there.

I have a Laravel application, where I am trying to install Alpine.js (Using NPM) together with wire-elements/modal. In my app.js file I have this:

require("./bootstrap");
require("alpinejs");

window.Alpine = Alpine;

Alpine.start();

I am loading the app.js file in my app.blade.php view file:

    <!-- Scripts -->
    <script src="{{ mix('js/app.js') }}" defer></script>
    <script src="{{ mix('js/modal.js') }}" ></script>

This gives me an error like the below though:

Uncaught TypeError: Cannot read properties of undefined (reading 'get')

If I remove Alpine.start(); from my app.js file, the error goes away (but Alpine is not working then).

Activity

  1. PhiloNL commented on Feb 22, 2022

    @PhiloNL
    Contributor

    I would recommend adding the import before the Alpine definition:

    require('../../vendor/wire-elements/modal/resources/js/modal')
    
    window.Alpine = Alpine
    Alpine.start()
    
  2. locked and limited conversation to collaborators on Feb 22, 2022
  3. converted this issue into a discussion #177 on Feb 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions