5

I am trying to deploying my website on Netlify from my GitHub.

However I am stuck to the following error:

11:37:19 AM: failed during stage 'deploying site': Invalid filename 'node_modules/es5-ext/date/#/format.js'. Deployed filenames cannot contain # or ? characters

I tried to delete and upgrade the module es5-ext but the error persists.

Magofoco
  • 5,098
  • 6
  • 35
  • 77
  • 1
    I got the same error while deploying the next.js project.[here](https://stackoverflow.com/questions/65873472/how-to-deal-with-error-deploy-failed-due-to-an-error-in-netlify-plugin-deploy) is my question. – Josh Thomas Jan 25 '21 at 11:29

2 Answers2

7

I don't know if i'm too late to this but I just ran into this issues here's what I did which fixed my issues

  • base directory : yourApps
  • build command : CI= npm run build
  • publish directory : yourApps/build

I used craco in my react apps because I needed it to work with Tailwind css , I don't know if this will work for you , but that solution worked for me

Ben
  • 71
  • 1
  • 3
0

My first answer is a question: Why are you deploying your node_modules folder? That is generally not needed on static websites: they're used to build the site, but then not needed at runtime, since, well, "runtime" is just "send this file" not "run this code" on the Netlify CDN server. Perhaps you've set your "publish directory" wrong in the site's build & deploy settings and are deploying your source code too, rather than just the finished build?

In case you do for some reason need to deploy node_modules for some reason, you can in general do so. The message is quite clear - don't send filenames with # or ? in them. Those are not valid filenames per the HTTP spec - # is for designating anchors, and everything after the # is used client-side and thus won't map correctly to your file. ? is for denoting query string parameters and similarly won't work as you're intending to read the file whose name contains ? but rather cutting off the filename that the server will (attempt to) serve, before the ? character.

fool
  • 3,044
  • 20
  • 28
  • Netlify is not just for static sites. You can run Node projects via "Functions" in Netlify. This is the error I'm running into as well. I don't see a way around this either. Simply installing netlify-lambda as a devDependency installs the es5-ext package - it contains the ./# directory that causes the problem. – Stewart Anderson Apr 30 '19 at 04:03
  • The way around it is not to send files with those characters in. Doesn't matter if you want to deploy node modules - that's ok - but you can't have illegal filenames in a deploy, period. So, remove that before the deploy (perhaps a workflow like `npm run build && netlify-lambda build && rm -rf functions/node_modules/es5-ext/date` would do the trick?) – fool May 01 '19 at 16:51