0

I am running

sudo docker run -d --name cloud-portal -v /opt/stack/dockercloudportal/config.js:/opt/fiware-cloud-portal/config.js -p 8000:8000 cloud-portal

But it gives me nodejs error as below:

/opt/fiware-cloud-portal/node_modules/express/node_modules/debug/src/node.js:120
exports.inspectOpts = Object.keys(process.env).filter(key => {
                                                           ^
SyntaxError: Unexpected token >
    at Module._compile (module.js:439:25)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/opt/fiware-cloud-portal/node_modules/express/node_modules/debug/src/index.js:9:19)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)

Do I have to add any more dependencies? Docker image has been build successfully but docker container goes to exit state.

1
  • 7
    Your docker image most likely contains an old version of Node that does not support lambdas. Make sure you build it with a specific version of Node that you have tested your code on. Commented Jan 7, 2019 at 12:30

1 Answer 1

1

You are using old version of node image in Docker.Use normal function rather than using Fat arrow Function(=>). It is not supported on the older version of node. Advantages of Arrow function-
1 this in arrow function points to the parents.
2 It creates writing function short.

You can also write the line without using fat arrow function.

exports.inspectOpts = Object.keys(process.env).filter(function(key) {
//Your Code Here
})
Sign up to request clarification or add additional context in comments.

2 Comments

Can I upgrade the nodejs version in docker itself? I am running "sudo apt install nodejs in Dockerfile and it is installing nodejs by default". How can I install latest version of nodejs in docker?
Use carbonalpine:latest image. It contains the version which supports fat Arrow function out of the box and its size is small too. It is the smallest image possible for linux distribution used in docker.

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.