Automated build failing because babel settings seem to be ignored

I’m building and deploying a Vuejs app and I’m able to build this locally and setup a separate site within Netlify to just upload the builds manually, but I’d really like the automated builds to work. It seems to be ignoring my babel settings to drop the console log lines. I’m getting a bunch of error Unexpected console statement no-console errors in the deploy logs.

Any help would be much appreciated!

Welcome @lasershow!

Could you maybe share how you configured your babel and the line of code where it’s happening?

I’m using this npm package: npm install babel-plugin-transform-remove-console --save-dev

Here’s my babel.config.js:

module.exports = { presets: [ '@vue/cli-plugin-babel/preset' ], env:{ production: { plugins: ["transform-remove-console"] } } }

It builds fine locally, but when it builds on Netlify, it throws an error on the first console.log() function.

Hey @lasershow, to me it seems like you forgot to add the options?

Check this link:

1 Like

I tried adding the options but that didn’t resolve the issue. I think the options are for excluding certain types of logs that you want to keep in the files (e.g. errors and warnings).

Is there a way to determine if the netlify build environment has access to all the things that my local build environment has? Maybe its just not taking my babel.config.js into consideration during build?

Looks like someone else is having a similar issue: Production build fails due to eslint `console.log()` errors, possible issue with NODE_ENV

Hiya, I wanted to see if you were still experiencing this or had found a fix? @Dennis and I suggested in another thread moving your dev dependencies to be production dependencies so they’ll definitely be available during build.

@divya also had some suggestions in the other thread you linked:

Want to check out the repo she links there and/or try the dependencies suggestion, and let us know how it goes?

I tried moving the babel remove console package to prod dependencies but it didn’t work. I’ve noticed that sometimes when I build locally it will fail with the same console errors. But I just run “npm run build” again and it will work. So there’s definitely something strange going on with the build. For now I’m just working on a small side project on my own so having the CI working isn’t a big deal. I’m just building locally and uploading the /dist folder to Netlify manually which is working for me just fine for now.

I’ll keep my eye on this thread in case someone figures it out though. Thanks!

Seems likely that if the build fails locally and rerunning it works, that would lead to consistent failures here - since we don’t re-run in the old copy of the build but in a totally fresh checkout without any artifacts available from previous runs.

I’d be working to troubleshoot the local build so it completes reliably, before trying to debug here - since the failure in our CI seems like an “expected” failure in my opinion, based on your local behavior.

Yeah probably right @fool. It’s probably an issue with the vue CLI build command. When I get it figured out I’ll post an update here.

great, thank you for doing that!

hi @lasershow - I’m having exactly the same problem - did you manage to solve it by any chance?

@some no i haven’t really tried to resolve it yet since I have a workaround for now. But it would be really nice to be able to use Netlify’s build preview feature which doesn’t work with manual uploads.

I cross-posted on the VueJS form as well if you want to follow there: "Remove console" not always applied - #3 by lasershow - Get Help - Vue Forum