Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.6k views
in Technique[技术] by (71.8m points)

vue打包npm run build打包图片发生error出错

image
这是一个vue项目的打包,npm run build后如下错误,截图这仅仅是众多错误中的一个错误,其他错误都是类似的。我把他完整地复制下来了,试了很多方法,比如修改src为如下代码还是不行
image

ERROR Failed to compile with 14 errors error in ./src/assets/pic_8.png

Module build failed (from ./node_modules/image-webpack-loader/index.js):
Error: 'E: H5convertH5convert-weicheng ode_modulespngquant-binvendorpngquant.exe' ? ? ?? ? е?

     ?   
at notFoundError (E:其他工作H5convertH5convert-weicheng
ode_modulesimagemin-pngquant
ode_modulescross-spawnlibenoent.js:6:26)
at verifyENOENT (E:其他工作H5convertH5convert-weicheng
ode_modulesimagemin-pngquant
ode_modulescross-spawnlibenoent.js:40:16)
at ChildProcess.cp.emit (E:其他工作H5convertH5convert-weicheng
ode_modulesimagemin-pngquant
ode_modulescross-spawnlibenoent.js:27:25)
at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)

@ ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"eb53340a-vue-loader-template"}!./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/views/Convert_weicheng.vue?vue&type=template&id=b6659c2c&scoped=true& 7:1984-2021
@ ./src/views/Convert_weicheng.vue?vue&type=template&id=b6659c2c&scoped=true&
@ ./src/views/Convert_weicheng.vue
@ ./src/router.js
@ ./src/main.js
@ multi ./src/main.js

求大佬能解析一下,谢谢


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

配置一下路径别名试试还报错不:

vue.config.js

configureWebpack: {
    resolve: {
      alias: {
        '@': path.resolve(__dirname, 'src')
      }
    }
  },

html:

<img src="@/assets/pic.png" alt="">

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...