I'm struggling to get TypedJS working on my Laravel site. I installed it using npm and added the files to my resources/assets/js/app.js
file like so:
/* default code */
require('../../../node_modules/typed.js/lib/typed.min.js');
require('./typedjs');
typedjs.js
looks like this:
var typed = new Typed('#header-search-input', {
strings: ["Los Angeles", "90210", "Vans Spinning Away Video"],
attr: 'placeholder',
typeSpeed: 30
});
And the complete console error I'm getting says:
Uncaught ReferenceError: Typed is not defined
at Object.disposed (app.js:47337)
at __webpack_require__ (app.js:20)
at Object.<anonymous> (app.js:13901)
at __webpack_require__ (app.js:20)
at Object.<anonymous> (app.js:13869)
at __webpack_require__ (app.js:20)
at app.js:63
at app.js:66
Feel like I'm not requiring the right file for typed.min.js
or I need to include others, but not sure what they'd be.
You’re not assigning your typed.js module to a variable. You have require(typed.min.js);
. You need var Typed = require(typed.min.js);