簡體   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

2) npm 同時檢查npm install --unsafe perm

3) npm start

4) npm install sharp

但是我仍然有同樣的問題請解決我的問題。

這是我的 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"
  }
}

我在 Mac 上遇到了同樣的錯誤, 這解決了我的問題

基本上:

  • 刪除 node_modules 文件夾
  • xcode-select --install
  • 關閉和打開終端
  • yarn install (我認為它也適用於npm install

我有同樣的問題並解決了

npm install sharp

  1. npm 重建 --verbose sharp

這個單行命令幫助了我。 這是一個魔法。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM