Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

91
Visualizações
Webpack bundling lodash throws syntax error

I am a newbie to module bundlers and following this video to learn how to use Webpack: https://www.youtube.com/watch?v=5IG4UmULyoA

This is my incredibly simple package.json file:

{
  "name": "t1",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "build": "webpack"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "lodash": "^4.17.21"  
  },
  "devDependencies": {
    "webpack": "^5.69.1",
    "webpack-cli": "^4.9.2"
  }
}

I installed lodash and imported its camelCase function as followed in my src/index.js:

import { camelCase } from 'lodash';
console.log(camelCase('hello world'));

I built it by npm run build and a bundled file in the dist/main.js is created, just like in the video that I linked above.

I embedded the bundled dist/main.js script into my index.html and it throws Uncaught SyntaxError: Invalid or unexpected token in main.js line 2.

Tested in different browsers: Opera, Chrome and Edge but no difference and since bundled dist/main.js looks very complicated and minified, I can't understand what is wrong with it.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda