旁注:我已经使用相同的方法进行了大约3次部署,但是现在突然不起作用了。。。让我觉得刚才用heroku更新了一些内容??? IDK
试图将我的MERN Stack应用程序推送到heroku,但出现错误,这是我的package.json文件:
{
"name": "jordanwebsite",
"version": "1.0.0",
"description": "",
"main": "server.js",
"scripts": {
"start": "node server.js",
"server": "nodemon server.js",
"test": "echo \"Error: no test specified\" && exit 1",
"client-install": "npm install --prefix client",
"client": "npm start --prefix client",
"dev": "concurrently \"npm run server\" \"npm run\tclient\"",
"heroku-postbuild": "cd client && NPM_CONFIG_PRODUCTION=false npm install && npm run build"
},
"author": "Jordan Harris",
"license": "ISC",
"dependencies": {
"axios": "^0.18.0",
"body-parser": "^1.18.3",
"concurrently": "^4.1.0",
"express": "^4.16.4",
"nodemon": "^1.18.9"
}
}
以下是日志:
$ git push heroku master
Enumerating objects: 40, done.
Counting objects: 100% (40/40), done.
Delta compression using up to 8 threads
Compressing objects: 100% (38/38), done.
Writing objects: 100% (40/40), 2.39 MiB | 637.00 KiB/s, done.
Total 40 (delta 0), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Node.js app detected
remote:
remote: -----> Creating runtime environment
remote:
remote: NPM_CONFIG_LOGLEVEL=error
remote: NODE_ENV=production
remote: NODE_MODULES_CACHE=true
remote: NODE_VERBOSE=false
remote:
remote: -----> Installing binaries
remote: engines.node (package.json): unspecified
remote: engines.npm (package.json): unspecified (use default)
remote:
remote: Resolving node version 10.x...
remote: Downloading and installing node 10.15.1...
remote: Using default npm version: 6.4.1
remote:
remote: -----> Building dependencies
remote: Installing node modules (package.json)
remote:
remote: > nodemon@1.18.9 postinstall /tmp/build_1c67c2822e7364298c69e79a4318103a/node_modules/nodemon
remote: > node bin/postinstall || exit 0
remote:
remote: Love nodemon? You can now support the project via the open collective:
remote: > https://opencollective.com/nodemon/donate
remote:
remote: added 340 packages from 197 contributors and audited 2497 packages in
10.466s
remote: found 0 vulnerabilities
remote:
remote: Running heroku-postbuild
remote:
remote: > jordanwebsite@1.0.0 heroku-postbuild /tmp/build_1c67c2822e7364298c69e79a4318103a
remote: > cd client && NPM_CONFIG_PRODUCTION=false npm install && npm run build
remote:
remote: added 1963 packages from 688 contributors and audited 35917 packages in 45.094s
remote: found 0 vulnerabilities
remote:
remote:
remote: > client@0.1.0 build /tmp/build_1c67c2822e7364298c69e79a4318103a/client
remote: > react-scripts build
remote:
remote: Creating an optimized production build...
remote: Failed to compile.
remote:
remote: Failed to minify the bundle. Error: static/js/main.4d56311f.chunk.js from Terser
remote: TypeError: Cannot read property 'minify' of undefined
remote: at compiler.run (/tmp/build_1c67c2822e7364298c69e79a4318103a/client/node_modules/react-scripts/scripts/build.js:169:23)
remote: at finalCallback (/tmp/build_1c67c2822e7364298c69e79a4318103a/client/node_modules/webpack/lib/Compiler.js:210:39)
remote: at hooks.done.callAsync.err (/tmp/build_1c67c2822e7364298c69e79a4318103a/client/node_modules/webpack/lib/Compiler.js:226:13)
remote: at AsyncSeriesHook.eval [as callAsync] (eval at create (/tmp/build_1c67c2822e7364298c69e79a4318103a/client/node_modules/tapable/lib/HookCodeFactory.js:32:10), <anonymous>:6:1)
remote: at AsyncSeriesHook.lazyCompileHook (/tmp/build_1c67c2822e7364298c69e79a4318103a/client/node_modules/tapable/lib/Hook.js:154:20)
remote: at onCompiled (/tmp/build_1c67c2822e7364298c69e79a4318103a/client/node_modules/webpack/lib/Compiler.js:224:21)
remote: at hooks.afterCompile.callAsync.err (/tmp/build_1c67c2822e7364298c69e79a4318103a/client/node_modules/webpack/lib/Compiler.js:553:14)
remote: at AsyncSeriesHook.eval [as callAsync] (eval at create (/tmp/build_1c67c2822e7364298c69e79a4318103a/client/node_modules/tapable/lib/HookCodeFactory.js:32:10), <anonymous>:6:1)
remote: at AsyncSeriesHook.lazyCompileHook (/tmp/build_1c67c2822e7364298c69e79a4318103a/client/node_modules/tapable/lib/Hook.js:154:20)
remote: at compilation.seal.err (/tmp/build_1c67c2822e7364298c69e79a4318103a/client/node_modules/webpack/lib/Compiler.js:550:30)
remote: at AsyncSeriesHook.eval [as callAsync] (eval at create (/tmp/build_1c67c2822e7364298c69e79a4318103a/client/node_modules/tapable/lib/HookCodeFactory.js:32:10), <anonymous>:6:1)
remote: at AsyncSeriesHook.lazyCompileHook (/tmp/build_1c67c2822e7364298c69e79a4318103a/client/node_modules/tapable/lib/Hook.js:154:20)
remote: at hooks.optimizeAssets.callAsync.err (/tmp/build_1c67c2822e7364298c69e79a4318103a/client/node_modules/webpack/lib/Compilation.js:1295:35)
remote: at AsyncSeriesHook.eval [as callAsync] (eval at create (/tmp/build_1c67c2822e7364298c69e79a4318103a/client/node_modules/tapable/lib/HookCodeFactory.js:32:10), <anonymous>:6:1)
remote: at AsyncSeriesHook.lazyCompileHook (/tmp/build_1c67c2822e7364298c69e79a4318103a/client/node_modules/tapable/lib/Hook.js:154:20)
remote: at hooks.optimizeChunkAssets.callAsync.err (/tmp/build_1c67c2822e7364298c69e79a4318103a/client/node_modules/webpack/lib/Compilation.js:1286:32)
remote:
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! errno 1
remote: npm ERR! client@0.1.0 build: `react-scripts build`
remote: npm ERR! Exit status 1
remote: npm ERR!
remote: npm ERR! Failed at the client@0.1.0 build 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! /tmp/npmcache.tUXJH/_logs/2019-02-03T01_53_57_344Z-debug.log
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! errno 1
remote: npm ERR! jordanwebsite@1.0.0 heroku-postbuild: `cd client && NPM_CONFIG_PRODUCTION=false npm install && npm run build`
remote: npm ERR! Exit status 1
remote: npm ERR!
remote: npm ERR! Failed at the jordanwebsite@1.0.0 heroku-postbuild 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! /tmp/npmcache.tUXJH/_logs/2019-02-03T01_53_57_358Z-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 version not specified in package.json
remote: https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version
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 jorrharris-website.
remote:
To https://git.heroku.com/jorrharris-website.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/jorrharris-website.git'
答案 0 :(得分:1)
我也有同样的问题。我从.git-ignore删除了包锁,它起作用了。希望对您有所帮助。
答案 1 :(得分:1)
remote: packages or subtle bugs in production.
remote:
remote: - To use npm to install your application's dependencies please delete
remote: the yarn.lock file.
remote:
remote: $ git rm yarn.lock
remote:
remote: - To use yarn to install your application's dependences please delete
remote: the package-lock.json file.
remote:
remote: $ git rm package-lock.json
remote:
remote: https://help.heroku.com/0KU2EM53
remote:
remote: ! Push rejected, failed to compile Node.js app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to elevaform.
remote:
就我而言,rm -rf node_modules && yarn install
答案 2 :(得分:0)
我有同样的问题。我尝试了许多帖子中的许多建议,最终对我来说是在客户端文件夹中运行“ npm install terser@3.14.1 --save-dev”,然后添加“ npm install terser@3.14.1 --prefix客户端” ”到主package.json中的heroku-postbuild。现在应显示为:
“ heroku-postbuild”:“ NPM_CONFIG_PRODUCTION = false npm install --prefix客户端&& npm install terser@3.14.1 --prefix客户端&& npm run build --prefix客户端”
这是假设主文件目录处理Mongo,Express和Node,然后一个客户文件夹处理React。希望这行得通。