У меня возникают проблемы при попытке запустить сайт Gatsby внутри контейнера Docker. Когда я выполняю gatsby develop
, я получаю следующую ошибку:
ERROR Failed to compile with 3 errors15:31:59
⠀
error in /.cache/json-store.js
⠀
Module Error (from /node_modules/eslint-loader/index.js):
/.cache/json-store.js
48:5 error '___emitter' is not defined no-undef
53:5 error '___emitter' is not defined no-undef
✖ 2 problems (2 errors, 0 warnings)
@ /.cache/root.js 19:0-37 68:31-40 77:38-47 84:27-36
@ /.cache/app.js
@ multi /node_modules/event-source-polyfill/src/eventsource.js
⠀
error in /.cache/socketIo.js
⠀
Module Error (from /node_modules/eslint-loader/index.js):
/.cache/socketIo.js
56:13 error '___emitter' is not defined no-undef
✖ 1 problem (1 error, 0 warnings)
@ /.cache/app.js 14:0-34 25:15-23
@ multi /node_modules/event-source-polyfill/src/eventsource.js
⠀
error in /.cache/loader.js
⠀
Module build failed (from /node_modules/eslint-loader/index.js):
TypeError: Cannot read property 'type' of null
Occurred while linting /cache/loader.js:30
at Object.VariableDeclarator
(/node_modules/eslint-plugin-react/lib/util/usedPropTypes.js:464:21)
at updatedRuleInstructions.(anonymous function)
(/node_modules/eslint-plugin-react/lib/util/Components.js:780:47)
at listeners.(anonymous function).forEach.listener
(/node_modules/eslint/lib/util/safe-emitter.js:45:58)
at Array.forEach (<anonymous>)
at Object.emit (/node_modules/eslint/lib/util/safe-emitter.js:45:38)
at NodeEventGenerator.applySelector
(/node_modules/eslint/lib/util/node-event-generator.js:251:26)
at NodeEventGenerator.applySelectors
(/node_modules/eslint/lib/util/node-event-generator.js:280:22)
at NodeEventGenerator.enterNode (/node_modules/eslint/lib/util/node-event-generator.js:294:14)
at CodePathAnalyzer.enterNode
(/node_modules/eslint/lib/code-path-analysis/code-path-analyzer.js:632:23)
at nodeQueue.forEach.traversalInfo (/node_modules/eslint/lib/linter.js:752:32)
@ /.cache/app.js 17:0-57 21:0-21 50:2-8 51:2-8 52:15-21 52:50-56 52:80-86
@ multi /node_modules/event-source-polyfill/src/eventsource.js
⠀
✖ 「wdm」:
ERROR in /.cache/json-store.js
Module Error (from /node_modules/eslint-loader/index.js):
/.cache/json-store.js
48:5 error '___emitter' is not defined no-undef
53:5 error '___emitter' is not defined no-undef
✖ 2 problems (2 errors, 0 warnings)
@ /.cache/root.js 19:0-37 68:31-40 77:38-47 84:27-36
@ /.cache/app.js
@ multi /node_modules/event-source-polyfill/src/eventsource.js
(webpack)-hot-middleware/client.js?path=/__webpack_hmr&reload=true&overlay=false /.cache/app
ERROR in /.cache/socketIo.js
Module Error (from /node_modules/eslint-loader/index.js):
/.cache/socketIo.js
56:13 error '___emitter' is not defined no-undef
✖ 1 problem (1 error, 0 warnings)
@ /.cache/app.js 14:0-34 25:15-23
@ multi /node_modules/event-source-polyfill/src/eventsource.js
(webpack)-hot-middleware/client.js?path=/__webpack_hmr&reload=true&overlay=false /.cache/app
ERROR in /.cache/loader.js
Module build failed (from /node_modules/eslint-loader/index.js):
TypeError: Cannot read property 'type' of null
Occurred while linting /cache/loader.js:30
at Object.VariableDeclarator
(/node_modules/eslint-plugin-react/lib/util/usedPropTypes.js:464:21)
at updatedRuleInstructions.(anonymous function)
(/node_modules/eslint-plugin-react/lib/util/Components.js:780:47)
at listeners.(anonymous function).forEach.listener
(/node_modules/eslint/lib/util/safe-emitter.js:45:58)
at Array.forEach (<anonymous>)
at Object.emit (/node_modules/eslint/lib/util/safe-emitter.js:45:38)
at NodeEventGenerator.applySelector
(/node_modules/eslint/lib/util/node-event-generator.js:251:26)
at NodeEventGenerator.applySelectors
(/node_modules/eslint/lib/util/node-event-generator.js:280:22)
at NodeEventGenerator.enterNode (/node_modules/eslint/lib/util/node-event-generator.js:294:14)
at CodePathAnalyzer.enterNode
(/node_modules/eslint/lib/code-path-analysis/code-path-analyzer.js:632:23)
at nodeQueue.forEach.traversalInfo (/node_modules/eslint/lib/linter.js:752:32)
ℹ 「wdm」: Failed to compile.
Подумав, что это может быть вызвано какими-либо особенностями моего проекта, я запустил новый, используя Gatsby по умолчанию, и сначала получил следующую ошибку:
error Error in "/node_modules/gatsby-transformer-sharp/gatsby-node.js":
Error: 'linux-x64' binaries cannot be used on the 'linuxmusl-x64' platform. Pl ease remove the
'node_modules/sharp/vendor' directory and run 'npm install'.
Я удалил node_modules
(полагая, что это может быть некоторая несовместимость между зависимостями моей локальной среды и зависимостей в контейнере Docker) и попытался снова, и в тот момент я получил ту же ошибку, что и раньше.
Это мои package.json
:
{
"name": "gatsby-starter-default",
"private": true,
"description": "A simple starter to get up and developing quickly with Gatsby",
"version": "0.1.0",
"author": "Kyle Mathews <mathews.kyle@gmail.com>",
"dependencies": {
"gatsby": "^2.10.4",
"gatsby-image": "^2.2.3",
"gatsby-plugin-manifest": "^2.2.0",
"gatsby-plugin-offline": "^2.2.0",
"gatsby-plugin-react-helmet": "^3.1.0",
"gatsby-plugin-sharp": "^2.2.1",
"gatsby-source-filesystem": "^2.1.0",
"gatsby-transformer-sharp": "^2.2.0",
"prop-types": "^15.7.2",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-helmet": "^5.2.1"
},
"devDependencies": {
"prettier": "^1.18.2"
},
"keywords": [
"gatsby"
],
"license": "MIT",
"scripts": {
"build": "gatsby build",
"develop": "gatsby develop",
"format": "prettier --write src/**/*.{js,jsx}",
"start": "npm run develop",
"serve": "gatsby serve",
"test": "echo \"Write tests! -> https://gatsby.dev/unit-testing\""
},
"repository": {
"type": "git",
"url": "https://github.com/gatsbyjs/gatsby-starter-default"
},
"bugs": {
"url": "https://github.com/gatsbyjs/gatsby/issues"
}
}
и мой Dockerfile (хотя я столкнулся с той же проблемой в небольших вариациях):
FROM node:alpine
# Also exposing VSCode debug ports
EXPOSE 8000 9929 9230
RUN apk add --no-cache python make g++ \
&& apk add vips-dev fftw-dev build-base \
--update-cache \
--repository https://alpine.global.ssl.fastly.net/alpine/edge/community \
--repository https://alpine.global.ssl.fastly.net/alpine/edge/main \
&& rm -fR /var/cache/apk/*
RUN npm install -g gatsby-cli yarn
WORKDIR .
COPY ./package.json .
RUN yarn install && yarn cache clean
COPY . .
ENTRYPOINT yarn install && gatsby develop -H 0.0.0.0
Проблема, похоже, связана с зависимостями, но я понял это сразу после клонирования одного из стартеров Гэтсби, поэтому я предполагаю, что они должны быть правы. Кроме того, проект работает отлично, если я выполняю его непосредственно в локальной системе (без Docker), так что, может быть, это несовместимость между образом node
и зависимостями Gatsby?
Заранее спасибо за помощь!