gatsbyjs / gatsby

The best React-based framework with performance, scalability and security built in.
https://www.gatsbyjs.com
MIT License
55.28k stars 10.31k forks source link

gatsby-transformer-sharp missing node module when running gatsby develop or gatsby build #28863

Closed LarsEjaas closed 3 years ago

LarsEjaas commented 3 years ago

Description

After reinstalling npm, my Gatsby project is failing when trying to build or develop.

Steps to reproduce

Clear steps describing how to reproduce the issue. Please link to a reproduction, this makes your issue much easier to diagnose (seriously).

How to Make a Minimal Reproduction: https://www.gatsbyjs.com/contributing/how-to-make-a-reproducible-test-case/

Expected result

What should happen?

Actual result

I get the following error in the terminal:

Error in "C:\Users\larse.LARS-HP\portfolio\node_modules\gatsby-transformer-sharp\gatsby-node.js": Cannot find module 'C:\Users\larse.LARS-HP\portfolio\node_modules\image-q\dist\iq.js'. Please verify that the package.json has a valid "main" entry.

I have tried reinstalling Gatsby-transformer sharp with:

npm install gatsby-transformer-sharp gatsby-plugin-sharp

I have tried installing all dependencies for the Gatsby package:

npm install --save gatsby-cli

I have tried fixing npm by running:

npm audit fix npm audit fix --force

Environment

System: OS: Windows 10 10.0.19041 CPU: (8) x64 Intel(R) Core(TM) i5-8265U CPU @ 1.60GHz Binaries: Node: 15.0.1 - C:\Program Files\nodejs\node.EXE Yarn: 1.22.5 - C:\Program Files (x86)\Yarn\bin\yarn.CMD npm: 7.0.3 - C:\Program Files\nodejs\npm.CMD Languages: Python: 3.9.0 - /c/Python39/python Browsers: Chrome: 87.0.4280.88 Edge: Spartan (44.19041.423.0), Chromium (87.0.664.66) npmPackages: gatsby: ^2.29.3 => 2.29.3 gatsby-background-image: ^1.3.1 => 1.3.1 gatsby-cli: ^2.12.69 => 2.16.2 gatsby-image: ^2.5.0 => 2.5.0 gatsby-plugin-brotli: ^2.0.0 => 2.0.0 gatsby-plugin-manifest: ^2.6.1 => 2.9.1 gatsby-plugin-offline: ^3.4.0 => 3.4.0 gatsby-plugin-postcss: ^3.4.0 => 3.4.0 gatsby-plugin-preact: ^4.2.0 => 4.2.0 gatsby-plugin-react-helmet: ^3.4.0 => 3.4.0 gatsby-plugin-react-i18next: ^0.0.27 => 0.0.27 gatsby-plugin-react-svg: ^3.0.0 => 3.0.0 gatsby-plugin-sharp: ^2.8.0 => 2.8.0 gatsby-plugin-transition-link: ^1.20.5 => 1.20.5 gatsby-remark-images: ^3.8.0 => 3.8.0 gatsby-remark-prismjs: ^3.10.0 => 3.10.0 gatsby-source-filesystem: ^2.5.0 => 2.5.0 gatsby-transformer-remark: ^2.12.0 => 2.12.0 gatsby-transformer-sharp: ^2.6.0 => 2.6.0 npmGlobalPackages: gatsby-cli: 2.16.2

ascorbic commented 3 years ago

Hi. Could you update your plugins to the latest versions? Your version of gatsby-plugin-sharp is quite old

LarsEjaas commented 3 years ago

Hi. Could you update your plugins to the latest versions? Your version of gatsby-plugin-sharp is quite old

Hi ascorbic, thanks for helping out! Updating got me a bit further, but I now 2 webpack errors instead:

` ERROR #98124 WEBPACK

Generating JavaScript bundles failed

Can't resolve 'gatsby-link' in 'C:\Users\larse.LARS-HP\portfolio.cache'

If you're trying to use a package make sure that 'gatsby-link' is installed. If you're trying to use a local file make sure that the path is correct.

File: .cache\navigation.js

ERROR #98124 WEBPACK

Generating JavaScript bundles failed

Can't resolve 'gatsby-react-router-scroll' in 'C:\Users\larse.LARS-HP\portfolio.cache'

If you're trying to use a package make sure that 'gatsby-react-router-scroll' is installed. If you're trying to use a local file make sure that the path is correct.

File: .cache\production-app.js`

I tried manually installing 'gatsby-link' and 'gatsby-react-router-scroll' but it didn't make a difference.

After the update my Gatsby install looks like this: System: OS: Windows 10 10.0.19041 CPU: (8) x64 Intel(R) Core(TM) i5-8265U CPU @ 1.60GHz Binaries: Node: 15.0.1 - C:\Program Files\nodejs\node.EXE Yarn: 1.22.5 - C:\Program Files (x86)\Yarn\bin\yarn.CMD npm: 7.0.3 - C:\Program Files\nodejs\npm.CMD Languages: Python: 3.9.0 - /c/Python39/python Browsers: Chrome: 87.0.4280.88 Edge: Spartan (44.19041.423.0), Chromium (87.0.664.66) npmPackages: gatsby: ^2.30.0 => 2.30.0 gatsby-background-image: ^1.3.1 => 1.3.1 gatsby-image: ^2.9.0 => 2.9.0 gatsby-plugin-brotli: ^2.0.0 => 2.0.0 gatsby-plugin-manifest: ^2.10.0 => 2.10.0 gatsby-plugin-offline: ^3.8.0 => 3.8.0 gatsby-plugin-postcss: ^3.5.0 => 3.5.0 gatsby-plugin-preact: ^4.5.0 => 4.5.0 gatsby-plugin-react-helmet: ^3.8.0 => 3.8.0 gatsby-plugin-react-i18next: ^0.0.27 => 0.0.27 gatsby-plugin-react-svg: ^3.0.0 => 3.0.0 gatsby-plugin-sharp: ^2.12.0 => 2.12.0 gatsby-plugin-transition-link: ^1.20.5 => 1.20.5 gatsby-remark-images: ^3.9.0 => 3.9.0 gatsby-remark-prismjs: ^3.11.0 => 3.11.0 gatsby-source-filesystem: ^2.9.0 => 2.9.0 gatsby-transformer-remark: ^2.14.0 => 2.14.0 gatsby-transformer-sharp: ^2.10.0 => 2.10.0 npmGlobalPackages: gatsby-cli: 2.16.2

LarsEjaas commented 3 years ago

Thanks again for the help.

3rd time installing node_modules and updating did it!

I have no idea why it kept failing? But it is working again - thanks for helping ascorbic !

obinasBaba commented 3 years ago

Any change on this error?