1

I need to build a new version of a javascript Node.js app. I have the source code and the macOS and Windows installers for the previous version of the app.

How can I find what version of Node.js was used to build the previous version of the app, so I can use the same Node.js version to build my new version of the app?

I understand that version of Node.js could have been different when building the macOS version and the Windows version. Ideally, I'd like to know what version of Node.js was used for each platform, but if I can get at least one that would be sufficient for my needs.

UPDATE: package.json:

{
  "name": "LiteracyStarter",
  "description": "Literacy Starter",
  "version": "0.60.1",
  "activated": true,
  "private": true,
  "main": "./build/LiteracyStarter.html",
  "nodejs": true,
  "chromium-args": "--disable-web-security",
  "window": {
    "toolbar": true,
    "width": 1260,
    "height": 750,
    "icon": "./images/LiteracyStarterIcon.png",
    "show": false
  },
  "dependencies": {
    "archiver": "^2.1.1",
    "arraybuffer-to-buffer": "0.0.4",
    "babel-plugin-transform-object-rest-spread": "^6.23.0",
    "babel-plugin-transform-runtime": "^6.23.0",
    "babel-polyfill": "^6.23.0",
    "cf-encrypt": "^1.0.0",
    "cli-spinner": "^0.2.6",
    "co": "^4.6.0",
    "co-fs": "^1.2.0",
    "co-fs-extra": "^1.2.1",
    "d3-dsv": "^1.0.7",
    "decompress-zip": "^0.3.0",
    "dexie": "^1.5.1",
    "esrever": "^0.2.0",
    "form-data": "^2.2.0",
    "fs-extra": "^0.23.1",
    "fs-extra-promise": "^1.0.1",
    "fstream": "^1.0.11",
    "image-size": "^0.3.5",
    "is-online": "^5.2.0",
    "jssha": "^2.3.1",
    "jszip": "^2.6.1",
    "lodash": "^3.10.1",
    "markdown-it": "^8.3.1",
    "memoizejs": "^0.1.1",
    "moment": "^2.18.1",
    "parse-error": "^0.2.0",
    "portscanner": "^1.2.0",
    "promise-alert": "^0.1.1",
    "promisify-node": "^0.4.0",
    "pseries": "^1.0.3",
    "quill": "^0.20.1",
    "react": "^15.6.1",
    "react-addons-perf": "^15.4.2",
    "react-dom": "^15.6.1",
    "read-json-stream": "^1.1.0",
    "redux": "^3.7.2",
    "request": "^2.81.0",
    "rimraf": "^2.6.1",
    "rmrf-promise": "^1.1.0",
    "simple-sort": "^0.1.2",
    "socket.io": "^1.7.4",
    "socket.io-client": "^1.7.4",
    "socket.io-stream": "^0.9.1",
    "superagent": "^1.8.5",
    "sweetalert": "^1.1.3",
    "system-font-families": "^1.0.0",
    "ttfinfo": "^0.2.0",
    "unzip": "^0.1.11",
    "uuid": "^3.1.0",
    "webpack": "^3.8.1",
    "workerjs": "^0.1.1",
  },
  "optionalDependencies": {
    "appdmg": "^0.4.5"
  },
  "devDependencies": {
    "babel-cli": "^6.6.5",
    "babel-core": "^6.7.0",
    "babel-loader": "^6.2.4",
    "babel-plugin-syntax-async-functions": "^6.13.0",
    "babel-plugin-transform-es2015-modules-commonjs": "^6.18.0",
    "babel-preset-es2015": "^6.6.0",
    "babel-preset-react": "^6.5.0",
    "babel-register": "^6.9.0",
    "colors": "^1.1.2",
    "eslint": "^2.13.1",
    "eslint-plugin-react": "^4.3.0",
    "express": "^4.13.1",
    "grunt": "^0.4.5",
    "grunt-babel": "^6.0.0",
    "grunt-cli": "^1.3.2",
    "grunt-contrib-copy": "^0.8.0",
    "grunt-contrib-cssmin": "^0.12.3",
    "grunt-contrib-requirejs": "^0.4.4",
    "grunt-contrib-uglify": "^0.8.0",
    "grunt-contrib-watch": "^0.6.1",
    "grunt-nw-builder": "^3.1.0",
    "grunt-sloc": "^0.6.0",
    "grunt-webpack": "^3.0.2",
    "mocha": "^2.2.4",
    "nw-builder": "^3.1.0",
    "react-tools": "^0.13.3",
    "requirejs": "^2.1.17",
    "s3": "^4.4.0",
    "should": "^8.4.0",
    "single-line-log": "^1.1.2",
    "underscore.string": "^3.0.3"
  },
  "scripts": {
    "start": "cd build && nw .",
    "dev-start": "cd build && NODE_ENV=development nw . --load-extension=../../react-devtools",
    "build": "npm install && bower install && grunt build && cd build && npm install --production",
    "build-native": "node build-native.js",
    "localization-helper": "cd localizationHelper && http-server",
    "code-generator": "node ./code-generator/code-generator.js",
    "generate-docs": "jsdoc app-node -r -d docs-node && jsdoc app-client/js -r -d docs-client",
    "watch-node": "babel app-node --watch --out-dir build/app-node",
    "watch-client": "webpack --watch --progress",
    "watch-all": "grunt watch",
    "compile-setup-scripts": "node compile-setup-scripts.js",
    "comment": "For node 10.x, we have to add git-core to the PATH when we run win-complete-build.  See https://github.com/appveyor/ci/issues/2420 for an example.",
    "win-complete-build": "PATH=%PATH%;C:\\Program Files\\Git\\mingw64\\libexec\\git-core && npm run build && npm run build-native && npm run compile-setup-scripts",
    "test-sy-utils": "mocha --compilers js:babel-register ./test/sy-utils-tests.js",
    "test-flashcards": "mocha --compilers js:babel-register ./test/flashcard-generator-tests.js",
    "build-native-linux": "cd build-native/LiteracyStarter/linux64/ && node-deb -- **"
  },
  "cutoffDate": "",
  "preLiteracyVersion": "0.20.2",
  "id": "47479c35-18d9-4265-ad85-af5a73080450"
}

David Burson
  • 2,947
  • 7
  • 32
  • 55
  • Why you need the Node.js version in this case? Why can't you just use any Node version which works? Is node also bundled as a part of the app? – Tarun Lalwani May 11 '20 at 06:44
  • Upgrading to a new version of Node may potentially break something in the app. I'd prefer to avoid a thorough manual retesting of everything in the app right now (it is large and complex). – David Burson May 11 '20 at 14:52
  • `Node.js` is backward compatible. As long as you have the `package.json` in your source code which has all the correct version in it. This shouldn't be a problem with the NodeJS version – Tarun Lalwani May 12 '20 at 04:47
  • Node.js does deprecate APIs and remove them eventually (for example, https://nodejs.org/api/deprecations.html). My concern is that our code may use an API that has now been removed, or may rely on a bug in Node.js that was fixed in a later version of Node.js. – David Burson May 12 '20 at 15:23
  • Can you post your `package.json` at least to see if there is any possible recommendation – Tarun Lalwani May 13 '20 at 04:05
  • I added my package.json. Thanks. – David Burson May 13 '20 at 18:43
  • Looking at `"comment": "For node 10.x, we have to add git-core to the PATH when we run win-complete-build. See https://github.com/appveyor/ci/issues/2420 for an example.",` it should be safe enough to use stable version of `10.x` series, else the original author will not have put this comment – Tarun Lalwani May 14 '20 at 06:12
  • Duplicate of: https://stackoverflow.com/questions/39472715/how-to-determine-the-node-js-version-from-source-code – Toastrackenigma May 16 '20 at 05:13

1 Answers1

3

Node.js doesn't get bundled with the source code of apps. The package.json might have a section called "engines" in which it will state what version you should be using.

If the root package.json doesn't have the "engines" section, then it may be posable that the some of the dependencies do say which version they require to be used. It would be kind of annoying going through each one to check, so a good way would be just to download a version of Node and run npm install. If everything works, then you know that the Node version the app was created in is most likely older (its a bit tedious, I know).

Another thing you could look for (but might not be to helpful) would be to check when the files of the source code were created (especially the package.json file), and find the Node version that was released around that time. This wont be as accurate as the first method but it will give you a working version of Node.

When it comes down to it though, its probably always best to use the most up to date version (or the most recent LTS version) as they come with all the latest security patches and improvements.

Mr. Simmons
  • 448
  • 3
  • 14