导入错误:无法从“ apollo-link-state / lib / bundle.umd.js”中找到模块“ graphql”

时间:2018-09-16 09:07:49

标签: reactjs graphql apollo

我正在尝试使用graphql后端(elixir / phoenix)设置React / Apollo前端。我做了npm install apollo-boost react-apollo graphql --save,然后尝试在我的index.js中import ApolloClient from "apollo-boost";,但是我得到了

Uncaught Error: Cannot find module 'graphql' from 'apollo-link-state/lib/bundle.umd.js'
    at require (app.js:61)
    at expanded (app.js:34)
    at app.js:148
    at connectionRemoveConfig.test (bundle.umd.js:6)
    at bundle.umd.js:9
    at bundle.umd.js:151
    at initModule (app.js:42)
    at require (app.js:59)
    at expanded (app.js:34)
    at app.js:148

在我的浏览器控制台中。我找不到任何相关问题。你能指出出什么问题了吗? 这是我的package.json

{
  "repository": {},
  "license": "MIT",
  "scripts": {
    "deploy": "brunch build --production",
    "watch": "brunch watch --stdin"
  },
  "dependencies": {
    "apollo-boost": "^0.1.16",
    "babel-preset-react": "^6.24.1",
    "graphql": "^14.0.2",
    "phoenix": "file:../deps/phoenix",
    "phoenix_html": "file:../deps/phoenix_html",
    "react": "^16.5.1",
    "react-apollo": "^2.1.11",
    "react-dom": "^16.5.1"
  },
  "devDependencies": {
    "babel-brunch": "6.1.1",
    "brunch": "2.10.9",
    "clean-css-brunch": "2.10.0",
    "uglify-js-brunch": "2.10.0"
  }
}

谢谢您的时间。

1 个答案:

答案 0 :(得分:3)

我通过单独安装解决了该问题。npm install apollo-client apollo-cache-inmemory apollo-link-http react-apollo graphql-tag graphql --save