remix: Importing PNG/SVG from node_modules failing
What version of Remix are you using?
1.1.3
Steps to Reproduce
- Install
uswdsNPM module - In
app/routes/index.tsx, import an image withimport img from 'uswds/img/circle-124.png'and put on the page with<img src={img} alt="" /> - Run dev server
npm run devand load up the page.
Expected Behavior
Circle image should be displayed
Actual Behavior
I get the following error:
C:\Users\jkjustjoshing\Documents\myrepo\node_modules\uswds\dist\img\circle-124.png:1
�PNG
SyntaxError: Invalid or unexpected token
at Object.compileFunction (node:vm:352:18)
at wrapSafe (node:internal/modules/cjs/loader:1031:15)
at Module._compile (node:internal/modules/cjs/loader:1065:27)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (C:\Users\jkjustjoshing\Documents\myrepo\build\index.js:446:36)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 4
- Comments: 18 (6 by maintainers)
Commits related to this issue
- fix(dev): treat imported assets from node_modules as external Fixes #1909. — committed to lpsinger/remix by lpsinger a year ago
Fixed by #6813
I guess that’s why my current workaround works: