cncjs: Latest Docker image throws: Error: Cannot find module '@babel/polyfill'

Description

Describe the issue or feature request in detail. Take a screenshot or record a video will be helpful.

Versions

  • CNCjs: 1.10.2 (Docker latest)
  • Node.js: 6.x
  • NPM: 5.x

How Do You Install CNCjs?

  • NPM
  • Download the CNCjs Desktop Application
  • Docker

CNC Controller

  • Grbl
  • Smoothieware
  • TinyG/g2core

Hardware

  • Raspberry Pi
  • Desktop or Laptop
  • Mobile Device

Operating System

  • Not Applicable
  • Windows
  • Mac
  • Linux

I am using the cncjs:latest docker container. (Also present in older images) The container throws following error on start:

`internal/modules/cjs/loader.js:905 throw err; ^

Error: Cannot find module ‘@babel/polyfill’ Require stack:

/opt/cncjs/entrypoint
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
at Function.Module._load (internal/modules/cjs/loader.js:746:27)
at Module.require (internal/modules/cjs/loader.js:974:19)
at require (internal/modules/cjs/helpers.js:101:18)
at Object. (/opt/cncjs/entrypoint:3:1)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:12)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:75:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/opt/cncjs/entrypoint' ]
}`

Does the Dockerimage use an old CNCJS version?

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 17 (6 by maintainers)

Most upvoted comments

Also now that I see that circleci is used I peeked at the https://github.com/cncjs/cncjs/blob/master/.circleci/config.yml file and it lays out all the commands run outside of the docker container build to get it to built. Not convenient for those who don’t want to install node/yarn/devEnv on their machine to build the docker image. Now I’ve got some CNC projects to work on!

Yep, can confirm that the issue is fixed. Thank you again.

PR opened: https://github.com/cncjs/cncjs/pull/831

It doesn’t fully work yet, there’s a problem with the handlebars template rendering I think. Getting close though.

Aha, ok that context helps. I see now that the existing Dockerfile starts out by copying ./dist/cncjs into the container, so the build process would have happened separately, outside the docker build context. Got it. Your npm run build-prod step makes sense now, the Yarn equivalent I think would be yarn run build-prod.

Install modules in yarn.lock ? or does yarn install modules in package.json

Yes and yes 👍 it’ll use yarn.lock first and fall back on package.json for upgrades. If Yarn works like NPM does, yarn --production would only use yarn.lock.

# Copy our dist/cncjs output ...

At this stage, the project is built and the assets are being copied to the build directory. I bet the image will work if the next few lines are simplified to:

# Don't understand enough, so I think there redundant commands above and below...
# npm install this, yarn install that...
WORKDIR $BUILD_DIR/cncjs
# RUN npm install           # The dists/cncjs (aka cncjs) dir has a package.json whys is this needed here?
RUN npm install --save @babel/polyfill # Adding in babel/polyfill here, but why can't this already done above in cncjs-source?
# RUN yarn --production     # No clue what this does, throwing kitchen sink.

Adding in babel/polyfill here, but why can’t this already done above in cncjs-source?

That’s the real question. The polyfill package should already be installed! Mysterious.

Just to give an update on the Dockerfile and building everything from scratch inside the build container. I am able to build from source a docker container by making a handful of changes to the Dockerfile. However, I think I’m doing too many steps. Comments/background appreciated on the RUN lines below:

#######################################
# Mucking about and figuring out how this
# could be built fully in a Docker container
# .....
# Copy our source into the container - This means that cncjs-source is a copy of the git repo
COPY . $BUILD_DIR/cncjs-source

# Install Yarn, then cncjs modules, then build
WORKDIR $BUILD_DIR/cncjs-source
RUN npm install -g yarn
RUN yarn install
RUN npm run build-prod

# Copy the built dist/cncjs and entrypoint over to the target cncjs dir
RUN cp -a dist/cncjs $BUILD_DIR/ && cp entrypoint $BUILD_DIR/cncjs

# Don't understand enough, so I think there redundant commands above and below...
# npm install this, yarn install that...
WORKDIR $BUILD_DIR/cncjs
RUN npm install
RUN npm install --save @babel/polyfill
RUN yarn --production

@emcniece ?

I can confirm that the latest image for me has this error, running v1.10.2:

root@buffalo:/srv/cncjs# docker ps | grep cncjs
4836893bc876   cncjs/cncjs:v1.10.2             "/opt/cncjs/entrypoi…"   3 hours ago   Restarting (1) 12 seconds ago                                                                                                                     cncjs-cnc-1

Docker Log:

Error: Cannot find module '@babel/polyfill'
Require stack:
- /opt/cncjs/entrypoint
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
    at Function.Module._load (internal/modules/cjs/loader.js:746:27)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:101:18)
    at Object.<anonymous> (/opt/cncjs/entrypoint:3:1)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:75:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '/opt/cncjs/entrypoint' ]
}
internal/modules/cjs/loader.js:905
  throw err;
  ^

The above repeats over and over as the container restarts.