question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

The problem with package.json and node_modules

See original GitHub issue

This is a Google provider related problem I encountered during usage.

Let’s pretend a user wants to use the Google Provider implementation. He would create (or download) a service. He would add a package.json file to his service directory so that he can install all the necessary packages and of course the Serverless google provider plugin (which is a npm package as well).

Now here are some minor problems we have to tackle:

The google-cloud and googleapis packages are huge (right now we include everything so that the developer has access to all Google Cloud service he needs). Solution: We can easily reduce this and only include the npm packages which are really needed for the deployment process (e.g. storage and functions, etc.). The user has to add the Google pacakges he need by hand to his service. Furthermore I’ve excluded the package.json file and node_modules directory in the boilerplate (see below).

The Google “handler” concept works a follows. The root directory needs a file named index.js, function.js or a package.json (with an entrypoint defined). This is a problem right now as the package.json is taken which has the Google Provider plugin as a dependency. Completely ignoring the index.js or function.js of the service (if the user won’t define it in the package.json which is not yet done by default). Solution: Right now I’ve excluded the package.json and node_modules directory in the boilerplate (see: https://github.com/serverless/boilerplate-googlecloudfunctions-nodejs/pull/2/files). This makes sure that the plugin works as expected. However package.json files or node_modules directories on the root level are currently not supported because of this. The user needs to add a directory, create a new package.json and add all the dependencies he wants to use for his service there. I hope that this is understandable. Otherwise please let me know. As already said. This is a problem currently only the Google implementation has and is not that super critical at the time of writing (although this might change once the Google Cloud Functions service is open for everyone and larger projects are developed) but definitely needs attention soon.

/cc @serverless/team

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
pmuenscommented, Apr 4, 2017

@codepreneur thanks for the update and taking the initiative!

0reactions
pmuenscommented, May 18, 2017

Just a quick update on this one. We’ve removed package.json form the excludes in all the examples, service templates and boilerplates for the Google integration (e.g. here https://github.com/serverless/serverless/pull/3644).

I’ll close this issue for now since the discussion can be continued in https://github.com/serverless/serverless/issues/2895

Read more comments on GitHub >

github_iconTop Results From Across the Web

How To Use Node.js Modules with npm and package.json
In this tutorial, you will manage packages with npm. The first step will be to create and understand the package.json file. You will...
Read more >
Local package.json exists, but node_modules missing
I was having a permission issue with running this, due to the closed-nature of my office VPN. This'll solve permission problems... sudo npm...
Read more >
Understanding dependency management with Node Modules
Some common issues I have seen developers face with node modules are often ... The main public registry for JS modules is Node...
Read more >
package.json - npm Docs
Description. This document is all you need to know about what's required in your package.json file. It must be actual JSON, not just...
Read more >
Missing Node Modules / Package.JSON issues / DO ...
Package file missing components (probably due to node modules missing; Tried to delete package / package-lock.json files and let Wappler install with no...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found