now-pipeline icon indicating copy to clipboard operation
now-pipeline copied to clipboard

Error: cannot find file .npmignore

Open AndreyNikiforov opened this issue 7 years ago • 25 comments

Trying to use now-pipeline and get:

Something went wrong Sometimes restarting pipeline can help Error: cannot find file .npmignore at lazyAssLogic (/usr/local/lib/node_modules/now-pipeline/node_modules/lazy-ass/index.js:110:14) at lazyAss (/usr/local/lib/node_modules/now-pipeline/node_modules/lazy-ass/index.js:115:28) at filenames.forEach.name (/usr/local/lib/node_modules/now-pipeline/src/index.js:118:9) at Array.forEach (native) at deploy (/usr/local/lib/node_modules/now-pipeline/src/index.js:117:17)

per now doc (https://zeit.co/docs/features/now-cli#selecting-files-and-directories-to-be-uploaded) .npmignore file is optional. Please advise.

AndreyNikiforov avatar Apr 19 '17 03:04 AndreyNikiforov

Hmm, if that is the case, it should not throw an exception there. Care to fix this and submit a pull request? I promise to merge it quickly.

bahmutov avatar Apr 19 '17 12:04 bahmutov

This looks like a important PR. Shall I contribute to it ?

karuppiah7890 avatar Aug 03 '17 18:08 karuppiah7890

What do you suggest we do about this ? pkgd module basically includes .npmignore too in the files. Do we ignore it in this line ?

karuppiah7890 avatar Aug 03 '17 18:08 karuppiah7890

Hi @karuppiah7890

Thank you for looking at this. I would make a list of optional filenames with .npmignore, check list of files to deploy against it. If the file is not found and it is in the optional filenames list, skip it

bahmutov avatar Aug 03 '17 18:08 bahmutov

@bahmutov Yeah, makes sense. I will look into it and see what other files are optional in now deployment.

karuppiah7890 avatar Aug 03 '17 18:08 karuppiah7890

I too am experiencing this issue for some reason. Is this due to an incorrect configuration on my end or is this affecting everyone?

wulfmann avatar Aug 04 '17 16:08 wulfmann

This is a weird issue and I do not completely understand when and why it happens. Might be because I use .gitignore file that is a sub for .npmignore?

bahmutov avatar Aug 04 '17 16:08 bahmutov

Can you run the tool with DEBUG=now-pipeline? This will show the files it is trying to deploy

bahmutov avatar Aug 04 '17 16:08 bahmutov

From CI?

wulfmann avatar Aug 04 '17 16:08 wulfmann

that's where it happens? sure on CI you can either set an environment variable or just update your CI file command, something like

script:
  - npm i -g now-pipeline
  - DEBUG=now-pipeline now-pipeline

bahmutov avatar Aug 04 '17 16:08 bahmutov

It happens both locally and from ci.

from debug:

+ [email protected]
added 112 packages in 5.33s
npm info ok 

+ DEBUG=now-pipeline now-pipeline
Fri, 04 Aug 2017 16:46:01 GMT now-pipeline deploying 11 files
Fri, 04 Aug 2017 16:46:01 GMT now-pipeline [ 'package.json',
  '.npmignore',
  'bitbucket-pipelines.yml',
  'data/test.json',
  'now.json',
  'readme.md',
  'rules.json',
  'src/handlers.js',
  'src/index.js',
  'src/product.js',
  'src/index.html' ]
Something went wrong
Sometimes restarting pipeline can help
Error: cannot find file .npmignore
    at lazyAssLogic (/usr/local/lib/node_modules/now-pipeline/node_modules/lazy-ass/index.js:110:14)
    at lazyAss (/usr/local/lib/node_modules/now-pipeline/node_modules/lazy-ass/index.js:115:28)
    at filenames.forEach.name (/usr/local/lib/node_modules/now-pipeline/src/index.js:122:9)
    at Array.forEach (native)
    at deploy (/usr/local/lib/node_modules/now-pipeline/src/index.js:121:17)
    at <anonymous>

wulfmann avatar Aug 04 '17 16:08 wulfmann

I don't have a .npmignore file in my repo, so is now-pipeline adding that somewhere?

I see it in the file array.

wulfmann avatar Aug 04 '17 16:08 wulfmann

no, this list comes from pkgd that for some reason thinks it should be part of the NPM published package. Hmm, https://github.com/inikulin/pkgd does not have any issues related to this file.

Do you want to fix this (I think it should be done like https://github.com/bahmutov/now-pipeline/issues/20#issuecomment-320054344) ? A pull request with the fix would be greatly appreciated.

bahmutov avatar Aug 04 '17 17:08 bahmutov

Yes I will try to get a PR up within the hour.

I've traced the requirement back to here: https://github.com/npm/fstream-npm/blob/master/fstream-npm.js#L300

It would seem that pkgd is just pulling that entire list and using that as it's requirements. I'm trying to figure out the best way to alter that.

wulfmann avatar Aug 04 '17 18:08 wulfmann

@wulfmann Woah

karuppiah7890 avatar Aug 04 '17 18:08 karuppiah7890

@wulfmann just have our own "optional" list?

bahmutov avatar Aug 04 '17 18:08 bahmutov

@bahmutov That's a big question to ask. But first, we need to check what now.sh considers optional, since if we don't include that, now.sh is gonna throw errors

karuppiah7890 avatar Aug 04 '17 18:08 karuppiah7890

For now, we can just keep .npmignore and see what other similar files are optional for now.sh deployment and not check for them

karuppiah7890 avatar Aug 04 '17 18:08 karuppiah7890

Yea that should work. I have an idea on how to add an optional list, just making sure I fully understand everything that’s going on.

wulfmann avatar Aug 04 '17 18:08 wulfmann

Though this is hardly a fix, adding an empty .npmignore resolves the issue.

I'm working on a fork to retool the whole file-checking section since there are a few different rules as to which file / property takes precedence.

I put the loop of 'readFileSync' of the filenames in a try catch instead and that allowed the function to continue without the presence of the .npmignore, but threw a 500 server error at the very end. I need to try it with the correct keys but I still think it's an error somewhere else.

I'll keep you guys updated but it will probably take me a few days to get to it. If you have any suggestions i'd love to hear them. This is a great module so I really want to contribute and continue using it.

wulfmann avatar Aug 04 '17 22:08 wulfmann

I'm experiencing this issue as well, debug output here:

https://gist.github.com/anonymous/4a5a337b210c4ecf8084652a83385a34

Do I create a .npmignore file in Travis?

spences10 avatar Jan 08 '18 08:01 spences10

Apologies that I never got back to this. I've opened a PR with a simple change that should solve the issue.

wulfmann avatar Jan 08 '18 17:01 wulfmann

@spences10 My changes were merged. Whenever the npm package is updated could you check and see if you are still experiencing that issue? I'm working on recreating the issue i had with it back in August to make sure it's all set, but it will likely be confirmed sooner by you.

wulfmann avatar Jan 08 '18 17:01 wulfmann

ok, published as 1.9.0

bahmutov avatar Jan 08 '18 17:01 bahmutov

I'll get on this shortly.

I'll take out the touch .npmignore from my .travis.yml so I'm hoping that will get me past this issue, I still haven't managed to get now-pipeline to push a build I can view with now ls from my terminal.

Thanks @wulfmann 👍

spences10 avatar Jan 09 '18 12:01 spences10