Home > Net >  Get TypeError When deploying A Mean.js Project into Heroku
Get TypeError When deploying A Mean.js Project into Heroku

Time:03-25

This is an old mean.js project. The project node version 4.4.4. I can run this project on my local machine using node 10.24.1.

When I deploy this project in heroku, many TypeErrors come in terminal while node-modules packages downloading. I followed some answers to solve this problem but unfortunately I can not succeed that is why I ask here.

My package-lock file is updated.

The Build Logs are as follows:

Enumerating objects: 28099, done.
Counting objects: 100% (28099/28099), done.
Delta compression using up to 6 threads
Compressing objects: 100% (15109/15109), done.
Writing objects: 100% (28099/28099), 58.86 MiB | 343.00 KiB/s, done.
Total 28099 (delta 10970), reused 27836 (delta 10797), pack-reused 0
remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> Building on the Heroku-20 stack
remote: -----> Deleting 1 files matching .slugignore patterns.
remote: -----> Determining which buildpack to use for this app
remote: -----> Node.js app detected
remote:        
remote: -----> Creating runtime environment
remote:        
remote:        NPM_CONFIG_LOGLEVEL=error
remote:        NODE_VERBOSE=false
remote:        NODE_ENV=production
remote:        NODE_MODULES_CACHE=true
remote:        
remote: -----> Installing binaries
remote:        engines.node (package.json):  4.4.4
remote:        engines.npm (package.json):   3.8.x
remote:        
remote:        Resolving node version 4.4.4...
remote:        Downloading and installing node 4.4.4...
remote:        Bootstrapping npm 3.8.x (replacing 2.15.1)...
remote:        npm 3.8.x installed
remote:        
remote: -----> Installing dependencies
remote:        Installing node modules (package.json   package-lock)
remote:        npm ERR! Linux 4.4.0-1101-aws
remote:        npm ERR! argv "/tmp/build_648a0567/.heroku/node/bin/node" "/tmp/build_648a0567/.heroku/node/bin/npm" "install" "--production=false" "--unsafe-perm" "--userconfig" "/tmp/build_648a0567/.npmrc"
remote:        npm ERR! node v4.4.4
remote:        npm ERR! npm  v3.8.9
remote:        npm ERR! code EMISSINGARG
remote:        
remote:        npm ERR! typeerror Error: Missing required argument #1
remote:        npm ERR! typeerror     at andLogAndFinish (/tmp/build_648a0567/.heroku/node/lib/node_modules/npm/lib/fetch-package-metadata.js:31:3)
remote:        npm ERR! typeerror     at fetchPackageMetadata (/tmp/build_648a0567/.heroku/node/lib/node_modules/npm/lib/fetch-package-metadata.js:51:22)
remote:        npm ERR! typeerror     at resolveWithNewModule (/tmp/build_648a0567/.heroku/node/lib/node_modules/npm/lib/install/deps.js:455:12)
remote:        npm ERR! typeerror     at /tmp/build_648a0567/.heroku/node/lib/node_modules/npm/lib/install/deps.js:456:7
remote:        npm ERR! typeerror     at /tmp/build_648a0567/.heroku/node/lib/node_modules/npm/node_modules/iferr/index.js:13:50
remote:        npm ERR! typeerror     at /tmp/build_648a0567/.heroku/node/lib/node_modules/npm/lib/fetch-package-metadata.js:37:12
remote:        npm ERR! typeerror     at addRequestedAndFinish (/tmp/build_648a0567/.heroku/node/lib/node_modules/npm/lib/fetch-package-metadata.js:82:5)
remote:        npm ERR! typeerror     at returnAndAddMetadata (/tmp/build_648a0567/.heroku/node/lib/node_modules/npm/lib/fetch-package-metadata.js:118:7)
remote:        npm ERR! typeerror     at pickVersionFromRegistryDocument (/tmp/build_648a0567/.heroku/node/lib/node_modules/npm/lib/fetch-package-metadata.js:135:20)
remote:        npm ERR! typeerror     at /tmp/build_648a0567/.heroku/node/lib/node_modules/npm/node_modules/iferr/index.js:13:50
remote:        npm ERR! typeerror This is an error with npm itself. Please report this error at:
remote:        npm ERR! typeerror     <http://github.com/npm/npm/issues>
remote:        npm ERR! Linux 4.4.0-1101-aws
remote:        npm ERR! argv "/tmp/build_648a0567/.heroku/node/bin/node" "/tmp/build_648a0567/.heroku/node/bin/npm" "install" "--production=false" "--unsafe-perm" "--userconfig" "/tmp/build_648a0567/.npmrc"
remote:        npm ERR! node v4.4.4
remote:        npm ERR! npm  v3.8.9
remote:        npm ERR! code EMISSINGARG
remote:        
remote:        npm ERR! typeerror Error: Missing required argument #1
remote:        npm ERR! typeerror     at andLogAndFinish (/tmp/build_648a0567/.heroku/node/lib/node_modules/npm/lib/fetch-package-metadata.js:31:3)
remote:        npm ERR! typeerror     at fetchPackageMetadata (/tmp/build_648a0567/.heroku/node/lib/node_modules/npm/lib/fetch-package-metadata.js:51:22)
remote:        npm ERR! typeerror     at resolveWithNewModule (/tmp/build_648a0567/.heroku/node/lib/node_modules/npm/lib/install/deps.js:455:12)
remote:        npm ERR! typeerror     at /tmp/build_648a0567/.heroku/node/lib/node_modules/npm/lib/install/deps.js:456:7
remote:        npm ERR! typeerror     at /tmp/build_648a0567/.heroku/node/lib/node_modules/npm/node_modules/iferr/index.js:13:50
remote:        npm ERR! typeerror     at /tmp/build_648a0567/.heroku/node/lib/node_modules/npm/lib/fetch-package-metadata.js:37:12
remote:        npm ERR! typeerror     at addRequestedAndFinish (/tmp/build_648a0567/.heroku/node/lib/node_modules/npm/lib/fetch-package-metadata.js:82:5)
remote:        npm ERR! typeerror     at returnAndAddMetadata (/tmp/build_648a0567/.heroku/node/lib/node_modules/npm/lib/fetch-package-metadata.js:118:7)
remote:        npm ERR! typeerror     at pickVersionFromRegistryDocument (/tmp/build_648a0567/.heroku/node/lib/node_modules/npm/lib/fetch-package-metadata.js:135:20)
remote:        npm ERR! typeerror     at /tmp/build_648a0567/.heroku/node/lib/node_modules/npm/node_modules/iferr/index.js:13:50
remote:        npm ERR! typeerror This is an error with npm itself. Please report this error at:
remote:        npm ERR! typeerror     <http://github.com/npm/npm/issues>
remote:        
remote:        npm ERR! Please include the following file with any support request:
remote:        npm ERR!     /tmp/build_648a0567/npm-debug.log
remote: 
remote: -----> Build failed

package.json file

{
  "name": "...",
  "description": "Full-Stack JavaScript with MongoDB, Express, AngularJS, and Node.js",
  "version": "0.0.1",
  "author": "...",
  "engines": {
    "node": "4.4.4",
    "npm": "3.8.x"
  },
  "scripts": {
    "start": "grunt",
    "debug": "grunt debug",
    "test": "grunt test",
    "postinstall": "bower install --config.interactive=false"
  },
  "dependencies": {
    "async": "~0.9.0",
    "body-parser": "~1.9.0",
    "bower": "~1.3.8",
    "chalk": "~0.5",
    "compression": "~1.2.0",
    "connect-flash": "~0.1.1",
    "connect-mongo": "^1.1.0",
    "connect-mongodb-session": "^2.1.1",
    "consolidate": "~0.10.0",
    "cookie-parser": "~1.3.2",
    "dotenv": "^16.0.0",
    "express": "^4.13.4",
    "express-session": "^1.13.0",
    "forever": "~0.11.0",
    "glob": "~4.0.5",
    "gridfs-stream": "^1.1.1",
    "grunt-cli": "~0.1.13",
    "helmet": "~0.5.0",
    "lodash": "^4.12.0",
    "method-override": "~2.3.0",
    "mongoose": "4.7.3",
    "morgan": "~1.4.1",
    "multer": "^1.1.0",
    "nodemailer": "~2.4.1",
    "passport": "~0.2.0",
    "passport-facebook": "~1.0.2",
    "passport-github": "~0.1.5",
    "passport-google-oauth": "~0.1.5",
    "passport-linkedin": "~0.1.3",
    "passport-local": "~1.0.0",
    "passport-twitter": "~1.0.2",
    "paypal-rest-sdk": "^1.6.8",
    "q": "^1.5.1",
    "stripe": "^4.6.0",
    "swig": "~1.4.1",
    "validator": "^5.2.0"
  },
  "devDependencies": {
    "grunt": "^1.0.1",
    "grunt-concurrent": "^2.3.0",
    "grunt-contrib-csslint": "^1.0.0",
    "grunt-contrib-cssmin": "^1.0.1",
    "grunt-contrib-jshint": "^1.0.0",
    "grunt-contrib-uglify": "^1.0.1",
    "grunt-contrib-watch": "^1.0.0",
    "grunt-env": "^0.4.4",
    "grunt-karma": "^1.0.0",
    "grunt-mocha-test": "^0.12.7",
    "grunt-ng-annotate": "^2.0.2",
    "grunt-nodemon": "^0.4.2",
    "karma": "^0.13.22",
    "karma-chrome-launcher": "^1.0.1",
    "karma-coverage": "^1.0.0",
    "karma-firefox-launcher": "^0.1.7",
    "karma-jasmine": "^1.0.2",
    "karma-phantomjs-launcher": "^1.0.0",
    "load-grunt-tasks": "^3.5.0",
    "mocha": "^2.4.5",
    "should": "^8.3.1",
    "supertest": "^1.2.0"
  }
}

As this project is run on node 10.24.1 on my local machine, it can build on heroku if heroku's node version is downgraded into 10.24.1 at runtime (if possible), I assume but I am not sure.

Please anyone answer this question or suggestion? Thanks in advance!

CodePudding user response:

Node.js 4.4.4 is absolutely ancient.

It doesn't even show up on this page of releases, which says in part:

After six months, odd-numbered releases (9, 11, etc.) become unsupported, and even-numbered releases (10, 12, etc.) move to Active LTS status and are ready for general use. LTS release status is "long-term support", which typically guarantees that critical bugs will be fixed for a total of 30 months.

Version 4.4 is well beyond its maintenance window, and I strongly urge you to upgrade this project.

Having said that, there's a good chance you can get Heroku to run Node.js 10 to match your local version. Heroku only officially supports the current and active LTS releases, but it doesn't prevent you from using older releases:

Since Heroku is based on a standard Ubuntu Linux stack, you can run most Node versions (>= 0.10.0) on the platform. However, the testing and support focus of the buildpack will be oriented around active LTS and Stable releases.

Update the engines section in your package.json:

  "engines": {
    "node": "10.x"
  },

I have also removed the npm version here, which should cause Heroku to use whatever version is bundled with the latest Node.js 10.x release.

Commit this change, then redeploy.

  • Related