[openstreetmap/openstreetmap-website] Unable to Run ESLint Inside Docker Container (Issue #4989)
Emin Kocan
notifications at github.com
Mon Jul 15 11:18:44 UTC 2024
### Problem
**Description:**
Following the instructions in the `DOCKER.md` file, I encountered errors when attempting to run `bundle exec rails eslint` inside the Docker container terminal.
**Steps to Reproduce:**
1. Follow the setup instructions in the `DOCKER.md` file.
2. Open a terminal in the Docker container.
3. Run the command: `bundle exec rails eslint`.
**Observed Behavior:**
The following error is displayed:
```bash
$ bundle exec rails eslint
warning: parser/current is loading parser/ruby30, which recognizes 3.0.7-compliant syntax, but you are running 3.0.2.
Please see https://github.com/whitequark/parser#compatibility-with-ruby-mri.
yarn run v1.22.22
$ /app/node_modules/.bin/eslint -c /app/config/eslint.js /app/app/assets/config/manifest.js /app/app/assets/javascripts/application.js /app/app/assets/javascripts/auth_providers.js /app/app/assets/javascripts/diary_entry.js /app/app/assets/javascripts/fixthemap.js /app/app/assets/javascripts/id.js /app/app/assets/javascripts/index/changeset.js /app/app/assets/javascripts/index/contextmenu.js /app/app/assets/javascripts/index/directions/fossgis_osrm.js /app/app/assets/javascripts/index/directions/fossgis_valhalla.js /app/app/assets/javascripts/index/directions/graphhopper.js /app/app/assets/javascripts/index/directions.js /app/app/assets/javascripts/index/export.js /app/app/assets/javascripts/index/history.js /app/app/assets/javascripts/index/layers/data.js /app/app/assets/javascripts/index/layers/notes.js /app/app/assets/javascripts/index/new_note.js /app/app/assets/javascripts/index/note.js /app/app/assets/javascripts/index/query.js /app/app/assets/javascripts/index/search.js /app/app/assets/javascripts/index.js /app/app/assets/javascripts/leaflet.key.js /app/app/assets/javascripts/leaflet.layers.js /app/app/assets/javascripts/leaflet.locate.js /app/app/assets/javascripts/leaflet.map.js /app/app/assets/javascripts/leaflet.note.js /app/app/assets/javascripts/leaflet.query.js /app/app/assets/javascripts/leaflet.share.js /app/app/assets/javascripts/leaflet.sidebar-pane.js /app/app/assets/javascripts/leaflet.sidebar.js /app/app/assets/javascripts/leaflet.zoom.js /app/app/assets/javascripts/login.js /app/app/assets/javascripts/matomo.js /app/app/assets/javascripts/messages.js /app/app/assets/javascripts/oauth.js /app/app/assets/javascripts/richtext.js /app/app/assets/javascripts/router.js /app/app/assets/javascripts/social_share_button.js /app/app/assets/javascripts/user.js /app/app/assets/javascripts/welcome.js /app/config/eslint.js
internal/modules/cjs/loader.js:818
throw err;
^
Error: Cannot find module 'node:util'
Require stack:
- /app/node_modules/eslint/bin/eslint.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)
at Function.Module._load (internal/modules/cjs/loader.js:667:27)
at Module.require (internal/modules/cjs/loader.js:887:19)
at require (internal/modules/cjs/helpers.js:85:18)
at getErrorMessage (/app/node_modules/eslint/bin/eslint.js:67:18)
at process.onFatalError (/app/node_modules/eslint/bin/eslint.js:123:3)
at process.emit (events.js:314:20)
at process._fatalException (internal/process/execution.js:165:25) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/app/node_modules/eslint/bin/eslint.js' ]
}
error Command failed with exit code 7.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
#
```
**Expected Behavior:**
The `bundle exec rails eslint` command should run without errors inside the Docker container.
**Environment:**
- Node.js version: v12.22.9
- Container OS: Ubuntu:22.04
### Description
**Possible Cause:**
After some investigation, I found that the issue might be due to the Node.js version not being specified. Specifying Node.js version 18 and rebuilding the Docker image resolved the issue.
**Workaround:**
```dockerfile
# After installing system packages before installing yarn globally
# Install Node.js 18 and npm
RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - \
&& apt-get install -y nodejs
```
```bash
$ bundle exec rails eslint
warning: parser/current is loading parser/ruby30, which recognizes 3.0.7-compliant syntax, but you are running 3.0.2.
Please see https://github.com/whitequark/parser#compatibility-with-ruby-mri.
yarn run v1.22.22
$ /app/node_modules/.bin/eslint -c /app/config/eslint.js /app/app/assets/config/manifest.js /app/app/assets/javascripts/application.js /app/app/assets/javascripts/auth_providers.js /app/app/assets/javascripts/diary_entry.js /app/app/assets/javascripts/fixthemap.js /app/app/assets/javascripts/id.js /app/app/assets/javascripts/index/changeset.js /app/app/assets/javascripts/index/contextmenu.js /app/app/assets/javascripts/index/directions/fossgis_osrm.js /app/app/assets/javascripts/index/directions/fossgis_valhalla.js /app/app/assets/javascripts/index/directions/graphhopper.js /app/app/assets/javascripts/index/directions.js /app/app/assets/javascripts/index/export.js /app/app/assets/javascripts/index/history.js /app/app/assets/javascripts/index/layers/data.js /app/app/assets/javascripts/index/layers/notes.js /app/app/assets/javascripts/index/new_note.js /app/app/assets/javascripts/index/note.js /app/app/assets/javascripts/index/query.js /app/app/assets/javascripts/index/search.js /app/app/assets/javascripts/index.js /app/app/assets/javascripts/leaflet.key.js /app/app/assets/javascripts/leaflet.layers.js /app/app/assets/javascripts/leaflet.locate.js /app/app/assets/javascripts/leaflet.map.js /app/app/assets/javascripts/leaflet.note.js /app/app/assets/javascripts/leaflet.query.js /app/app/assets/javascripts/leaflet.share.js /app/app/assets/javascripts/leaflet.sidebar-pane.js /app/app/assets/javascripts/leaflet.sidebar.js /app/app/assets/javascripts/leaflet.zoom.js /app/app/assets/javascripts/login.js /app/app/assets/javascripts/matomo.js /app/app/assets/javascripts/messages.js /app/app/assets/javascripts/oauth.js /app/app/assets/javascripts/richtext.js /app/app/assets/javascripts/router.js /app/app/assets/javascripts/social_share_button.js /app/app/assets/javascripts/user.js /app/app/assets/javascripts/welcome.js /app/config/eslint.js
/app/app/assets/javascripts/index.js
267:9 warning Unexpected alert no-alert
/app/app/assets/javascripts/index/directions.js
117:11 warning Unexpected alert no-alert
337:9 warning Unexpected 'todo' comment: 'TODO: collapse width of sidebar back to...' no-warning-comments
/app/app/assets/javascripts/index/directions/fossgis_osrm.js
4:1 warning Unexpected function declaration in the global scope, wrap in an IIFE for a local variable, assign as global property for a global variable no-implicit-globals
/app/app/assets/javascripts/index/directions/fossgis_valhalla.js
1:1 warning Unexpected function declaration in the global scope, wrap in an IIFE for a local variable, assign as global property for a global variable no-implicit-globals
/app/app/assets/javascripts/index/directions/graphhopper.js
1:1 warning Unexpected function declaration in the global scope, wrap in an IIFE for a local variable, assign as global property for a global variable no-implicit-globals
68:17 warning Unexpected 'todo' comment: 'TODO does graphhopper map instructions...' no-warning-comments
/app/app/assets/javascripts/social_share_button.js
2:1 warning Unexpected function declaration in the global scope, wrap in an IIFE for a local variable, assign as global property for a global variable no-implicit-globals
3:22 error Strings must use doublequote
.
.
.
✖ 38 problems (27 errors, 11 warnings)
25 errors and 0 warnings potentially fixable with the `--fix` option.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
$
```
### Screenshots
_No response_
--
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/issues/4989
You are receiving this because you are subscribed to this thread.
Message ID: <openstreetmap/openstreetmap-website/issues/4989 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20240715/0e0d849c/attachment-0001.htm>
More information about the rails-dev
mailing list