vercel: now.files does not allow overriding node_modules ignore

In the Alle monorepo style you follow the following structure:

./packages/node_modules/package1 ./packages/node_modules/package2

The problem is that now does not follow this same behavior and instead of /node_modules being ignored node_modules/**/* is ignored. This behavior differs from npm and means that if you have a directory called node_modules anywhere in your codebase, there is no way to override it. You can try to put exact file paths in now.files but it does not actually override the default node_modules/**/* ignore rule. Instead, if you run now -d you’ll see that now is actually just ignoring the directory as if the rule wasn’t there.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 1
  • Comments: 16 (10 by maintainers)

Most upvoted comments

FYI Future people, the solution was to add an .npmignore with:

!dist

Just to add to this now.files inside now.json is not overriding my .gitignore

Here’s the scenario

.gitignore

node_modules
dist

now.json

{
  "email": "some@email.com",
  "token": "my-token",
  "alias": "my-alias",
  "files": [
    "dist"
  ]
}

Snippet from package.json

"scripts": {
    "start": "serve dist",
    "test": "echo \"Error: no test specified\" && exit 1"
  },

now will not deploy my dist folder. If I run serve dist locally it works correctly, am I missing something obvious here? I’ve followed the documentation

Looks like that same .npmignore fix works the same for .dockerignore for anyone pulling out their hair over now.json for ignored files when using Docker

Ah, perfect, well that suits my case.

On Tue, 6 Dec 2016, 19:09 Leo Lamprecht, notifications@github.com wrote:

@remy https://github.com/remy Cool! Yea, we’ll document it in a special place very soon.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/zeit/now-cli/issues/157#issuecomment-265242303, or mute the thread https://github.com/notifications/unsubscribe-auth/AAA1hON-SfVa2A7jkEMyD-PVmEASAfbdks5rFbLbgaJpZM4LD4Wp .

I’d like to chime in on this to may offer another perspective where files support is useful.

I have .env in my project directory. However, to prevent it from going to github, my .gitignore file is:

.env

However, I need it to go up to my new Zeit instance, so I’d expect to have this in my package:

  "files": [ ".env" ]

But the now client doesn’t seem to respect that logic, and the .env file is not included in the deploy.

The only work around I have right now, is an inverse rule in my .npmignore:

!.env

Having this along side the .gitignore file does work, and the .env is deployed to the instance, but it’s pretty confusing (IMHO).

Got hit by this while trying to deploy a static version of Speedometer, which relies on assets in node_modules.

It seems like these ignores shouldn’t even apply for static deployments (i.e. now --static).