0

I'm building a vanilla js app and using CDN's works fine, but If I install an app like typed.js with npm, and then import it as import typed from 'typed.js' it works as it should on a local dev server.

However, once I push it and it's built on Netlify I get a console error stating: failed to resolve module specifier "typed.js". relative references must start with either "/", "./", or "../".

I have tried changing the import in every way I can think of like 'typed' , '/typed' , '/typed.js' , 'typed.js' , 'typed.js/lib/typed.js' , typed.js/src/typed.js' etc and using require instead of import.

Andrew Stegmaier
  • 3,429
  • 2
  • 14
  • 26
Stephan
  • 345
  • 2
  • 14
  • Should be as simple as `import typed from "./typed.js"` using Import statement — if *typed.js* is **not** inside *node_modules*. Otherwise use: `import typed from "typed"`. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import – Roko C. Buljan Jul 05 '22 at 00:37
  • yeah, I figured...I get the same error with emailjs so I'm not sure where the disconnect is, It must be with Netlify. – Stephan Jul 05 '22 at 00:39

1 Answers1

0

It ended up being a very easy fix with Netlify, I needed to change the publish directory to "dist" within the build settings.

Stephan
  • 345
  • 2
  • 14