简体   繁体   English

出现这种类型的错误:- 找不到模块“sharp”

[英]This type of error comes:- Cannot find module 'sharp'

Error: Cannot find module 'sharp'
  Require stack:
  - D:\Marketing\sbj-react\suburban\node_modules\gatsby-plugin-manifest\safe-sharp.js
  - D:\Marketing\sbj-react\suburban\node_modules\gatsby-plugin-manifest\gatsby-node.js
  - D:\Marketing\sbj-react\suburban\node_modules\gatsby\dist\bootstrap\resolve-module-exports.js
  - D:\Marketing\sbj-react\suburban\node_modules\gatsby\dist\bootstrap\load-plugins\validate.js
  - D:\Marketing\sbj-react\suburban\node_modules\gatsby\dist\bootstrap\load-plugins\load.js
  - D:\Marketing\sbj-react\suburban\node_modules\gatsby\dist\bootstrap\load-plugins\index.js
  - D:\Marketing\sbj-react\suburban\node_modules\gatsby\dist\bootstrap\index.js
  - D:\Marketing\sbj-react\suburban\node_modules\gatsby\dist\commands\develop.js
  - D:\Marketing\sbj-react\suburban\node_modules\gatsby-cli\lib\create-cli.js
  - D:\Marketing\sbj-react\suburban\node_modules\gatsby-cli\lib\index.js
  - D:\Marketing\sbj-react\suburban\node_modules\gatsby\dist\bin\gatsby.js

1) npm install 1) npm install

2) npm also check with npm install --unsafe perm 2) npm 同时检查npm install --unsafe perm

3) npm start 3) npm start

4) npm install sharp 4) npm install sharp

But still have same problem with me please resolve my question.但是我仍然有同样的问题请解决我的问题。

This is my package.json这是我的 package.json

{
  "name": "Ashish",
  "description": "Ashish Group Project",
  "version": "1.0.0",
  "author": "AshishBhangade <ashishbhangade@gmail.com>",
  "dependencies": {
    "axios": "^0.18.0",
    "babel-plugin-styled-components": "^1.10.0",
    "base-64": "^0.1.0",
    "bcryptjs": "^2.4.3",
    "bootstrap": "^4.1.3",
    "gatsby": "^2.0.53",
    "gatsby-background-image": "^0.9.11",
    "gatsby-graphiql-explorer": "^0.2.29",
    "gatsby-image": "^2.0.20",
    "gatsby-plugin-compression": "0.0.1",
    "gatsby-plugin-compression-v2": "^0.1.0",
    "gatsby-plugin-drift": "^1.0.0",
    "gatsby-plugin-facebook-analytics": "^2.0.2",
    "gatsby-plugin-facebook-pixel": "^1.0.3",
    "gatsby-plugin-facebook-sdk": "^1.0.6",
    "gatsby-plugin-google-analytics": "^2.0.9",
    "gatsby-plugin-google-gtag": "^1.0.8",
    "gatsby-plugin-google-tagmanager": "^2.0.7",
    "gatsby-plugin-hotjar": "^1.0.1",
    "gatsby-plugin-manifest": "^2.0.9",
    "gatsby-plugin-netlify": "^2.0.6",
    "gatsby-plugin-offline": "^2.0.21",
    "gatsby-plugin-react-helmet": "^3.0.2",
    "gatsby-plugin-robots-txt": "^1.4.0",
    "gatsby-plugin-sass": "^2.0.5",
    "gatsby-plugin-sentry": "^1.0.0",
    "gatsby-plugin-sharp": "^2.0.12",
    "gatsby-plugin-sitemap": "^2.0.4",
    "gatsby-plugin-styled-components": "^3.0.4",
    "gatsby-plugin-zopfli": "^1.0.2",
    "gatsby-source-apiserver": "^2.1.4",
    "gatsby-source-filesystem": "^2.0.8",
    "gatsby-transformer-sharp": "^2.1.8",
    "jquery": "^3.3.1",
    "logrocket": "^1.0.6",
    "logrocket-react": "^4.0.1",
    "moment": "^2.24.0",
    "moment-timezone": "^0.5.23",
    "node-sass": "^4.10.0",
    "perm": "^1.0.0",
    "react": "^16.6.3",
    "react-bootstrap": "^0.32.4",
    "react-bootstrap-time-picker": "^1.0.3",
    "react-datepicker": "^2.0.0",
    "react-device-detect": "^1.11.14",
    "react-dom": "^16.6.3",
    "react-ga": "^2.5.6",
    "react-helmet": "^5.2.0",
    "react-input-mask": "^2.0.4",
    "react-number-format": "^4.0.6",
    "react-otp-input": "^0.3.1",
    "react-phone-input-2": "^2.11.0",
    "react-places-autocomplete": "^7.2.1",
    "react-popper": "^1.3.2",
    "react-scroll": "^1.7.12",
    "react-select": "^3.0.8",
    "react-slick": "^0.23.2",
    "reactstrap": "^6.5.0",
    "slick-carousel": "^1.8.1",
    "socket.io-client": "^2.2.0",
    "styled-components": "^4.1.3",
    "universal-cookie": "^3.0.7"
  }
}

I was getting the same error on a mac and this fixed my issue我在 Mac 上遇到了同样的错误, 这解决了我的问题

Basically:基本上:

  • delete node_modules folder删除 node_modules 文件夹
  • xcode-select --install
  • close and open terminal关闭和打开终端
  • yarn install (I assume it would also work with npm install ) yarn install (我认为它也适用于npm install

I had the same problem and solved with我有同样的问题并解决了

npm install sharp

  1. npm rebuild --verbose sharp npm 重建 --verbose sharp

this single line command helped me.这个单行命令帮助了我。 This was a magic.这是一个魔法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM