netlify / netlify-plugin-gatsby

A build plugin to integrate Gatsby seamlessly with Netlify
https://www.npmjs.com/package/@netlify/plugin-gatsby
MIT License
92 stars 18 forks source link

Plugin cannot find module manifest.json #57

Closed indraneel closed 3 years ago

indraneel commented 3 years ago

Ran a clean cache build on Netlify with @netlify/plugin-gatsby installed, and it seems to be getting a dependency error in the Functions building step:

7:30:38 PM:   5. Functions bundling                                         
7:30:38 PM: ────────────────────────────────────────────────────────────────
7:30:38 PM: ​
7:30:38 PM: Packaging Functions from serverless-functions directory:
7:30:38 PM:  - gatsby/gatsby.js
7:30:38 PM:  - pgp-reform-feed/pgp-reform-feed.js
7:30:38 PM: ​
7:30:39 PM: ​
7:30:39 PM: ─────────────────────────────────────────────
7:30:39 PM: ────────────────────────────────────────────────────────────────
7:30:39 PM:   Dependencies installation error                               
7:30:39 PM: ────────────────────────────────────────────────────────────────
7:30:39 PM: ​
7:30:39 PM:   Error message
7:30:39 PM:   A Netlify Function failed to require a local file.
7:30:39 PM:   Please make sure the file exists and its path is correctly spelled.
7:30:39 PM: ​
7:30:39 PM:   In file "/opt/build/repo/serverless-functions/gatsby/gatsby.js"
7:30:39 PM:   Cannot find module '../../../.cache/functions/manifest.json' from '/opt/build/repo/serverless-functions/gatsby'

Not sure I totally understand the purpose of the template/ dir but it looks like this is where things break: https://github.com/netlify/netlify-plugin-gatsby/blob/main/plugin/src/templates/gatsby.js#L11 ?

Steps to reproduce

This was a Netlify build so tough to provide exact steps but I ran gatsby build on my gatsby v3 site.

The plugin seems to have added this to my .gitignore

# Local Netlify folder
.netlify
+# @netlify/plugin-gatsby ignores start
+serverless-functions/gatsby
+# @netlify/plugin-gatsby ignores end

this is my package.json

  "dependencies": {
    "@apollo/react-hooks": "4.0.0",
    "@mdx-js/mdx": "1.5.9",
    "@mdx-js/react": "1.5.8",
    "apollo-boost": "0.4.7",
    "colormap": "^2.3.1",
    "d3": "^6.1.1",
    "dompurify": "2.0.8",
    "firebase": "7.8.2",
    "firebaseui": "4.4.0",
    "gatsby": "^3.7.0",
    "gatsby-cli": "^3.7.0",
    "gatsby-image": "^3.7.0",
    "gatsby-plugin-canonical-urls": "^3.7.0",
    "gatsby-plugin-force-trailing-slashes": "^1.0.4",
    "gatsby-plugin-google-fonts": "^1.0.1",
    "gatsby-plugin-google-gtag": "^3.7.0",
    "gatsby-plugin-manifest": "^3.7.0",
    "gatsby-plugin-mdx": "2.7.0",
    "gatsby-plugin-meta-redirect": "^1.1.1",
    "gatsby-plugin-offline": "^4.7.0",
    "gatsby-plugin-open-graph-images": "^0.1.7",
    "gatsby-plugin-react-helmet": "^4.7.0",
    "gatsby-plugin-react-svg": "3.0.0",
    "gatsby-plugin-robots-txt": "^1.5.3",
    "gatsby-plugin-s3": "^0.3.4",
    "gatsby-plugin-sharp": "^3.7.0",
    "gatsby-remark-embedder": "^5.0.0",
    "gatsby-source-airtable": "^2.1.1",
    "gatsby-source-filesystem": "^3.7.0",
    "gatsby-source-graphql": "3.7.0",
    "gatsby-source-pg": "0.2.1",
    "gatsby-source-rss-feed": "^1.2.0",
    "gatsby-transformer-javascript-frontmatter": "^3.7.0",
    "gatsby-transformer-json": "3.7.0",
    "gatsby-transformer-rehype": "^2.0.0",
    "gatsby-transformer-sharp": "^3.7.0",
    "js-stats": "^1.0.5",
    "moment": "^2.27.0",
    "netlify-cms": "^2.10.51",
    "prop-types": "^15.7.2",
    "react": "^16.12.0",
    "react-aim-menu": "^1.0.12",
    "react-dom": "^16.12.0",
    "react-helmet": "^5.2.1",
    "react-inlinesvg": "1.2.0",
    "react-mailchimp-subscribe": "^2.1.0",
    "react-simple-maps": "^2.1.2",
    "react-svg-tooltip": "^0.0.11",
    "react-transition-group": "https://github.com/reactjs/react-transition-group.git#v1-stable",
    "rehype-slug": "^3.0.0",
    "throttle-debounce": "^2.3.0",
    "victory": "^35.0.8"
  },
  "devDependencies": {
    "@netlify/plugin-gatsby": "^0.0.2",
    "prettier": "^1.19.1"
  },

Expected behavior

Dependency should be found?

Environment

7:23:11 PM: Now using node v12.18.0 (npm v6.14.4)

ascorbic commented 3 years ago

@indraneel Thanks for the report! I think I know what the issue is here. It looks like it's related to your custom functions directory. I'll check things and should have a fix.

ascorbic commented 3 years ago

Released in v0.0.3