Heroku package.json问题

时间:2018-12-05 22:09:55

标签: reactjs laravel heroku npm package

Package.json:

    {
        "private": true,
        "scripts": {
                    ...
        },
        "devDependencies": {
            "axios": "^0.18",
            "babel-preset-react": "^6.23.0",
            "bootstrap": "^4.0.0",
            "cross-env": "^5.1",
            "jquery": "^3.2",
            "laravel-mix": "^2.0",
            "lodash": "^4.17.4",
            "popper.js": "^1.12",
            "react": "^16.2.0",
            "react-dom": "^16.2.0",
            "gh-pages": "^2.0.1",
            "react-icons": "^3.2.2",
            "react-redux": "^5.0.7",
            "react-scripts": "1.1.5",
            "redux": "^4.0.0",
            "redux-thunk": "^2.3.0",
            "styled-components": "^4.0.2"
        },
        "dependencies": {
            "react-router-dom": "^4.3.1"
        }
    }

部署laravel应用(带有react)后出现错误:

Uncaught Error: Cannot find module "react-redux"

我的控制台中存在空白站点,并且出现上述错误。

1 个答案:

答案 0 :(得分:1)

默认情况下,Heroku仅在部署时安装生产依赖项,因此通过运行dependencies在您package.json的{​​{1}}键下列出的依赖项。

将对您的应用至关重要的依赖项从npm install --production迁移到devDependencies,应该可以解决您的问题。

dependencies用于支持开发的事物,但对于运行应用的生产副本不是必需的,例如测试模块。