简体   繁体   中英

browserify throwing error: Unexpected character '�' (1:0) while parsing file: image.png

This sounds absolutely ridiculous but I cannot, for the life of me, display an inline image in my angular project scaffolded by webpack. Every time I use a valid path to the image (in either the <img> tag or in my require('/app/image.png') I get the error:

Unexpected character ' ' (1:0) while parsing file: /app/image.png

I have tried using just about every image loader, file loader, static loader, etc. i've tried different images and different locations for those images. Where am I going wrong?

Here's my current image loader from webpack.config.js:

{
  test: /\.png$/, 
  loader: "url-loader?limit=8192"
}

I see all these reference to including the loader in the require statement like:

require("url?limit=10000!/app/image.png");

Anytime i try anything similar in my /app/scripts/main.js file, I get this error:

Cannot find module 'url?limit=10000!/app/image.png' from '/Users/dmp/bidder-client/app/scripts'

I'm very confused :/

if you add the new images or resources file into your project,you should Reinstall your app rather than just refresh js. so,you should : react-native run-android

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM