1

All of a sudden, when updating the packages in my app using npm install, I get the following error:

module.exports = async process => {
                       ^^^^^^^
SyntaxError: Unexpected identifier
    at Object.exports.runInThisContext (vm.js:76:16)
    at Module._compile (module.js:542:28)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/opt/bitnami/nodejs/lib/node_modules/npm/bin/npm-cli.js:2:1)
    at Module._compile (module.js:570:32)

Having searched SO I have made sure that I'm running a recent version of Node (16.14.2), set the default alias to be this version, and removed older versions of node. My setup is now as follows:

{
  'app-name': '1.0.0',
  npm: '8.5.0',
  node: '16.14.2',
  v8: '9.4.146.24-node.20',
  uv: '1.43.0',
  zlib: '1.2.11',
  brotli: '1.0.9',
  ares: '1.18.1',
  modules: '93',
  nghttp2: '1.45.1',
  napi: '8',
  llhttp: '6.0.4',
  openssl: '1.1.1n+quic',
  cldr: '40.0',
  icu: '70.1',
  tz: '2021a3',
  unicode: '14.0',
  ngtcp2: '0.1.0-DEV',
  nghttp3: '0.1.0-DEV'
}

I can't update npm, or install npm directly using curl -qL https://www.npmjs.com/install.sh | sudo sh, which just returns 'Failed!'.

This is on a production server, so I'm looking to avoid complete re-installs, if possible.

1 Answer 1

1

I found the issue. The path to node was being modified by two files in my Bitnami distribution, which prevented the correct version being used.

I found the solution was to add /usr/local/bin to the path that gets exported from ~/.bashrc and /opt/bitnami/.bitnamirc, as described below.

https://community.bitnami.com/t/how-to-upgrade-nodejs-in-bitnami-server/57857/21?page=2

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.