2017-06-30 11 views
0

私はReactプロジェクトをHerokuに配備しようとしています。これまでは問題はありませんでしたが、現在は問題があります。バージョン管理のためだと思われます。それでもなお非常に新しいので、ここでいくつかの有用な入力を感謝することができます。herokuへのプロジェクトの展開に問題がある

ターミナルエラーメッセージ:

remote:  Installing any new modules (package.json) 
remote:   
remote:  > [email protected] postinstall /tmp/build_66d2f41eb413351a0a39128a0fae4330 
remote:  > NODE_ENV='production' webpack -p 
remote:   
remote:  sh: 1: webpack: not found 
remote:  npm ERR! file sh 
remote:  npm ERR! code ELIFECYCLE 
remote:  npm ERR! errno ENOENT 
remote:  npm ERR! syscall spawn 
remote:  npm ERR! [email protected] postinstall: `NODE_ENV='production' webpack -p` 
remote:  npm ERR! spawn ENOENT 
remote:  npm ERR! 
remote:  npm ERR! Failed at the [email protected] postinstall script. 
remote:  npm ERR! This is probably not a problem with npm. There is likely additional logging output above. 
remote:   
remote:  npm ERR! A complete log of this run can be found in: 
remote:  npm ERR!  /app/.npm/_logs/2017-06-30T10_39_42_230Z-debug.log 
remote: 
remote: -----> Build failed 
remote:   
remote:  We're sorry this build is failing! You can troubleshoot common issues here: 
remote:  https://devcenter.heroku.com/articles/troubleshooting-node-deploys 
remote:   
remote:  Some possible problems: 
remote:   
remote:  - node_modules checked into source control 
remote:  https://blog.heroku.com/node-habits-2016#9-only-git-the-important-bits 
remote:   
remote:  Love, 
remote:  Heroku 
remote:   
remote: !  Push rejected, failed to compile Node.js app. 
remote: 
remote: !  Push failed 
remote: Verifying deploy... 
remote: 
remote: ! Push rejected to d3-barchart-drhectapus. 
remote: 
To https://git.heroku.com/d3-barchart-drhectapus.git 
! [remote rejected] master -> master (pre-receive hook declined) 
error: failed to push some refs to 'https://git.heroku.com/d3-barchart-drhectapus.git' 

Package.json:

{ 
    "name": "react-boilerplate", 
    "version": "1.0.0", 
    "description": "Minimal boilerplate for react", 
    "main": "index.js", 
    "engines": { 
    "node": "6.10.2", 
    "npm": "5.0.4" 
    }, 
    "scripts": { 
    "dev": "webpack-dev-server --progress --inline --colors --hot --config ./webpack.config.js", 
    "postinstall": "NODE_ENV='production' webpack -p", 
    "start": "node server.js", 
    "test": "echo \"Error: no test specified\" && exit 1" 
    }, 
    "author": "", 
    "license": "ISC", 
    "babel": { 
    "presets": [ 
     "es2015", 
     "react", 
     "stage-2" 
    ] 
    }, 
    "devDependencies": { 
    "babel-core": "^6.24.1", 
    "babel-loader": "^7.0.0", 
    "babel-preset-es2015": "^6.24.1", 
    "babel-preset-react": "^6.24.1", 
    "babel-preset-stage-2": "^6.24.1", 
    "css-loader": "^0.28.0", 
    "node-sass": "^4.5.2", 
    "sass-loader": "^6.0.5", 
    "style-loader": "^0.16.1", 
    "webpack": "^2.4.1", 
    "webpack-dev-server": "^2.4.5" 
    }, 
    "dependencies": { 
    "axios": "^0.16.2", 
    "d3": "^4.9.1", 
    "react": "^15.5.4", 
    "react-dom": "^15.5.4", 
    "react-redux": "^5.0.5", 
    "redux": "^3.7.1", 
    "redux-thunk": "^2.2.0" 
    } 
} 

私は私のノード/ NPMのバージョンとは何かである疑いがありますか?私は最近ノードまたはnpmを更新しましたが(どちらが覚えていないか)、その後は問題が発生しているようです。ここに私がターミナルコマンドで気づいたものがあります:

remote: -----> Installing binaries 
remote:  engines.node (package.json): unspecified 
remote:  engines.npm (package.json): unspecified (use default) 
remote:   
remote:  Resolving node version 6.x via semver.io... 
remote:  Downloading and installing node 6.11.0... 
remote:  Detected package-lock.json: defaulting npm to version 5.x.x 
remote:  Resolving npm version 5.x.x via semver.io... 
remote:  Downloading and installing npm 5.0.4 (replacing version 3.10.10)... 
remote: 
remote: -----> Restoring cache 
remote:  Skipping cache restore (new-signature) 
+0

webpackを依存関係ではなく依存関係に入れることができます – VivekN

+0

まだ動作しません – doctopus

答えて

0

ここでの主な問題は、モジュールのwebpackがありません。これは、実稼働環境で必要なモジュールを定義しているpackage.jsonのdependenciesプロパティにリストされていないためです。

この問題を解決するには、dependenciesにwebpackを入れて、devDependenciesから削除する必要があります。

また、node_modulesがgitリポジトリに含まれていないことを確認する必要があります。したがって、herokuにデプロイする前に、gitignoreにnode_modulesを組み込み、gitリポジトリのnode_modulesを削除する必要があります。

+0

まだ動作しません – doctopus

+0

@JosephLiu node_modulesをgitにチェックインしますか? –

+0

それはどういう意味ですか?私がnode_modulesを.gitignoreにチェックインする前に、私はそれを行いましたが、まだ動作しません。 – doctopus

関連する問題