"未找到模块"何时将React应用程序部署到Heroku

时间:2017-09-03 15:03:30

标签: reactjs heroku node-modules

当我尝试将我的React应用程序(使用create-react-app制作)部署到Heroku时(使用create-react-app-buildpack),我收到以下错误:

Failed to compile.
Module not found: Error: Can't resolve 'jquery' in 
'/tmp/build_049d73accaf035b451adf36ac44318d3/src/components'
npm ERR! Linux 3.13.0-128-generic
npm ERR! argv 
"/tmp/build_049d73accaf035b451adf36ac44318d3/.heroku/node/bin/node" 
"/tmp/build_049d73accaf035b451adf36ac44318d3/.heroku/node/bin/npm" "run" 
"build"
npm ERR! node v6.11.2
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! life-quality-data@0.1.0 build: `react-scripts build`
npm ERR! Exit status 1

在我的电脑上测试时一切正常。我还在 package.json 中添加了jQuery作为依赖项:

{
  "name": "life-quality-data",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "axios": "^0.16.2",
    "dns": "^0.2.2",
    "fetch": "^1.1.0",
    "jquery": "^3.2.1",
    "node-sass-chokidar": "0.0.3",
    "numeral": "^2.0.6",
    "react": "^15.6.1",
    "react-dom": "^15.6.1",
    "react-router-dom": "^4.2.2",
    "react-scripts": "1.0.12",
    "xml2js": "^0.4.19"
  },
  "scripts": {
    "build-css": "node-sass-chokidar src/ -o src/",
    "watch-css": "npm run build-css && node-sass-chokidar src/ -o src/ --watch --recursive",
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  }
}

我想我可能会错过一条线。还有,它可能是 .gitignore 吗?因为在GitHub上节点模块被忽略了。

0 个答案:

没有答案