NPM - 为什么在 docker (buster) 上安装 reactjs 依赖项时满足版本要求时会出现 EBADEGINE 错误?

NPM - why do I get EBADEGINE errors while I meet versions requirements installing reactjs dependancies on docker (buster)?

在 docker 上尝试 运行 这个,但我收到 EBADENGINE 不受支持的引擎警告(并且随后的构建失败,我认为这至少在某种程度上是相关的)。

Docker 命令(从带有 package.json 文件的克隆项目根目录):

$ docker build --force-rm -t crmui:dev .
....

Step 6/9 : RUN npm install --legacy-peer-deps
 ---> Running in 34978d87b4eb
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: '@casl/react@2.1.1',
npm WARN EBADENGINE   required: { npm: '^6.0.0' },
npm WARN EBADENGINE   current: { node: 'v17.3.0', npm: '8.3.0' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: 'availity-reactstrap-validation-safe@2.6.1',
npm WARN EBADENGINE   required: { node: '>= 5.0.0', npm: '^3.0.0' },
npm WARN EBADENGINE   current: { node: 'v17.3.0', npm: '8.3.0' }
npm WARN EBADENGINE }

npm 高于要求的版本,node 也是。

Dockerfile:

FROM node:17.3-buster

WORKDIR /app

ENV PATH /app/node_modules/.bin:$PATH

# install app dependencies
COPY package.json ./
matter of preference
RUN npm install react-app-rewired -g
RUN npm install --legacy-peer-deps




# add app. the chmod avoids a user issue with docker & mkdir .chache; not a production-ready fix
COPY . ./
RUN mkdir node_modules/.cache && chmod -R 777 node_modules/.cache

# start app
CMD ["npm", "start"]

package.json 文件:

{
  "name": "vuexy-react-admin-dashboard",
  "version": "1.0.0",
  "private": true,
  "dependencies": {
    "@casl/ability": "5.2.2",
    "@casl/react": "2.1.1",
    "@fullcalendar/core": "5.7.2",
    "@fullcalendar/daygrid": "5.7.2",
    "@fullcalendar/interaction": "5.7.2",
    "@fullcalendar/list": "5.7.2",
    "@fullcalendar/react": "5.7.0",
    "@fullcalendar/timegrid": "5.7.2",
    "@fullcalendar/timeline": "5.7.2",
    "@hookform/resolvers": "1.3.4",
    "@uppy/react": "1.10.8",
    "animate.css": "4.1.1",
    "apexcharts": "^3.29.0",
    "availity-reactstrap-validation-safe": "2.6.1",
    "axios": "^0.24.0",
    "axios-mock-adapter": "1.19.0",
    "babel-plugin-react-intl": "5.1.18",
    "bootstrap": "4.5.2",
    "bs-stepper": "1.7.0",
    "chart.js": "2.9.4",
    "chroma-js": "2.1.0",
    "classnames": "2.2.6",
    "cleave.js": "1.6.0",
    "draft-js": "0.11.7",
    "draftjs-to-html": "0.9.1",
    "file-saver": "2.0.2",
    "flatpickr": "4.6.3",
    "history": "5.0.0",
    "html-to-draftjs": "1.5.0",
    "intl-messageformat": "7.8.4",
    "jquery": "3.5.1",
    "jsonwebtoken": "8.5.1",
    "leaflet": "1.6.0",
    "moment": "2.29.1",
    "nouislider": "14.6.2",
    "nouislider-react": "3.3.8",
    "postcss-rtl": "1.5.0",
    "prismjs": "^1.25.0",
    "prop-types": "15.7.2",
    "react": "17.0.1",
    "react-apexcharts": "1.3.6",
    "react-chartjs-2": "2.9.0",
    "react-contexify": "5.0.0",
    "react-copy-to-clipboard": "5.0.2",
    "react-country-flag": "2.0.1",
    "react-data-table-component": "6.11.2",
    "react-dom": "17.0.1",
    "react-draft-wysiwyg": "^1.14.7",
    "react-feather": "~2.0.3",
    "react-flatpickr": "3.9.1",
    "react-hook-form": "6.15.1",
    "react-intl": "3.11.0",
    "react-leaflet": "3.1.0",
    "react-paginate": "7.0.0",
    "react-perfect-scrollbar": "1.5.5",
    "react-player": "2.6.2",
    "react-rating": "2.0.5",
    "react-redux": "7.2.2",
    "react-router-dom": "5.2.0",
    "react-scripts": "4.0.2",
    "react-scroll-up": "1.3.7",
    "react-select": "4.0.2",
    "react-shepherd": "3.3.0",
    "react-slidedown": "2.4.5",
    "react-sortablejs": "6.0.0",
    "react-toastify": "7.0.3",
    "reactstrap": "8.6.0",
    "recharts": "2.0.4",
    "redux": "4.0.5",
    "redux-debounced": "0.5.0",
    "redux-thunk": "2.3.0",
    "sass": "1.26.8",
    "screenfull": "5.0.2",
    "sortablejs": "1.12.0",
    "styled-components": "5.1.1",
    "sweetalert2": "10.14.0",
    "sweetalert2-react-content": "3.0.1",
    "swiper": "6.0.4",
    "uppy": "1.21.2",
    "webpack": "4.43.0",
    "wnumb": "1.2.0",
    "xlsx": "^0.17.3",
    "yarn": "1.21.1",
    "yup": "0.32.8"
  },
  "scripts": {
    "start": "react-app-rewired start",
    "build": "react-app-rewired build",
    "test": "react-app-rewired test",
    "eject": "react-app-rewired eject",
    "lint": "eslint src/**/*.js src/**/*.jsx",
    "lint:fix": "eslint src/**/*.js --fix"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "devDependencies": {
    "@types/sortablejs": "1.10.6",
    "eslint": "7.8.0",
    "eslint-plugin-import": "2.22.0",
    "eslint-plugin-react": "7.20.6",
    "node-sass": "^4.13.1",
    "react-app-rewire-aliases": "^0.2.0",
    "react-app-rewire-postcss": "^3.0.2",
    "react-app-rewire-sass-rule": "^2.1.1",
    "react-app-rewired": "^2.1.6",
    "sass-loader": "^8.0.2"
  },
  "browserslist": [
    ">0.2%",
    "not dead",
    "not op_mini all"
  ]
}

这失败了: <...更多警告....>

npm WARN deprecated @formatjs/intl-unified-numberformat@3.3.7: We have renamed the package to @formatjs/intl-numberformat
npm ERR! code 1
npm ERR! path /app/node_modules/node-sass
npm ERR! command failed
npm ERR! command sh -c node scripts/build.js
npm ERR! Building: /usr/local/bin/node /app/node_modules/node-gyp/bin/node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
npm ERR! make: Entering directory '/app/node_modules/node-sass/build'
npm ERR!   g++ '-DNODE_GYP_MODULE_NAME=libsass' '-DUSING_UV_SHARED=1' '-DUSING_V8_SHARED=1' '-DV8_DEPRECATION_WARNINGS=1' '-DV8_DEPRECATION_WARNINGS' '-DV8_IMMINENT_DEPRECATION_WARNINGS' '-D_GLIBCXX_USE_CXX11_ABI=1' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-D__STDC_FORMAT_MACROS' '-DOPENSSL_NO_PINSHARED' '-DOPENSSL_THREADS' '

<....很多类似的东西...>

8_DEPRECATION_WARNINGS' '-DV8_IMMINENT_DEPRECATION_WARNINGS' '-D_GLIBCXX_USE_CXX11_ABI=1' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-D__STDC_FORMAT_MACROS' '-DOPENSSL_NO_PINSHARED' '-DOPENSSL_THREADS' '-DBUILDING_NODE_EXTENSION' -I/root/.node-gyp/17.3.0/include/node -I/root/.node-gyp/17.3.0/src -I/root/.node-gyp/17.3.0/deps/openssl/config -I/root/.node-gyp/17.3.0/deps/openssl/openssl/include -I/root/.node-gyp/17.3.0/deps/uv/include -I/root/.node-gyp/17.3.0/deps/zlib -I/root/.node-gyp/17.3.0/deps/v8/include -I../../nan -I../src/libsass/include  -fPIC -pthread -Wall -Wextra -Wno-unused-parameter -m64 -O3 -fno-omit-frame-pointer -fno-rtti -fno-exceptions -std=gnu++17 -std=c++0x -MMD -MF ./Release/.deps/Release/obj.target/binding/src/binding.o.d.raw   -c -o Release/obj.target/binding/src/binding.o ../src/binding.cpp
npm ERR! make: Leaving directory '/app/node_modules/node-sass/build'
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp verb cli [
npm ERR! gyp verb cli   '/usr/local/bin/node',
npm ERR! gyp verb cli   '/app/node_modules/node-gyp/bin/node-gyp.js',
npm ERR! gyp verb cli   'rebuild',
npm ERR! gyp verb cli   '--verbose',
npm ERR! gyp verb cli   '--libsass_ext=',
npm ERR! gyp verb cli   '--libsass_cflags=',
npm ERR! gyp verb cli   '--libsass_ldflags=',
npm ERR! gyp verb cli   '--libsass_library='
npm ERR! gyp verb cli ]
npm ERR! gyp info using node-gyp@3.8.0
npm ERR! gyp info using node@17.3.0 | linux | x64
npm ERR! gyp verb command rebuild []
npm ERR! gyp verb command clean []
npm ERR! gyp verb clean removing "build" directory
npm ERR! gyp verb command configure []
npm ERR! gyp verb check python checking for Python executable "python2" in the PATH
npm ERR! gyp verb `which` succeeded python2 /usr/bin/python2
npm ERR! gyp verb check python version `/usr/bin/python2 -c "import sys; print "2.7.16
npm ERR! gyp verb check python version .%s.%s" % sys.version_info[:3];"` returned: %j
npm ERR! gyp verb get node dir no --target version specified, falling back to host node version: 17.3.0
npm ERR! gyp verb command install [ '17.3.0' ]
npm ERR! gyp verb install input version string "17.3.0"
npm ERR! gyp verb install installing version: 17.3.0
npm ERR! gyp verb install --ensure was passed, so won't reinstall if already installed
npm ERR! gyp verb install version not already installed, continuing with install 17.3.0
npm ERR! gyp verb ensuring nodedir is created /root/.node-gyp/17.3.0
npm ERR! gyp verb created nodedir /root/.node-gyp
npm ERR! gyp http GET https://nodejs.org/download/release/v17.3.0/node-v17.3.0-headers.tar.gz
npm ERR! gyp http 200 https://nodejs.org/download/release/v17.3.0/node-v17.3.0-headers.tar.gz
npm ERR! gyp verb extracted file from tarball include/node/common.gypi
npm ERR! gyp verb extracted file from tarball include/node/config.gypi

<....压缩包错误一堆...>

pm ERR! gyp verb extracted file from tarball include/node/openssl/x509_no-asm.h
npm ERR! gyp verb extracted file from tarball include/node/zconf.h
npm ERR! gyp verb extracted file from tarball include/node/zlib.h
npm ERR! gyp verb tarball done parsing tarball
npm ERR! gyp verb check download content checksum, need to download `SHASUMS256.txt`... 
npm ERR! gyp verb checksum url https://nodejs.org/download/release/v17.3.0/SHASUMS256.txt
npm ERR! gyp http GET https://nodejs.org/download/release/v17.3.0/SHASUMS256.txt
npm ERR! gyp http 200 https://nodejs.org/download/release/v17.3.0/SHASUMS256.txt
npm ERR! gyp verb checksum data {"node-v17.3.0-aix-ppc64.tar.gz":"5300264598a643445378a51bf1d62242281ae602045934bf6fcacf6f6ba3abda","node-v17.3.0-darwin-arm64.tar.gz":"b504ba3628337f7ac2c67d04bf30e56082942345aa1a50e0e464f51df6662ff3","node-v17.3.0-darwin-arm64.tar.xz":"8f19364dd1159ce4ae8cfb3414508ee9092b8d3cf428b13c0d2aec7ac406e1ba","node-v17.3.0-darwin-x64.tar.gz":"d4fa7d01c3b08cecdb71eee1da27a5e0e2d31bd25ad3bee1807df95811c2ce3f","node-v17.3.0-darwin-x64.tar.xz":"eb231bd4ad5950ccb5572fc4bb099266a634d6788559424976c8e9fb7fc320d6","node-v17.3.0-headers.tar.gz":"9cb2ac1e9a3e7df31269699e02dcc55069cd1f27fd0417650fb95acf8f3e7a22","node-v17.3.0-headers.tar.xz":"b5f1f5bdb2405e626448100aa50879f859288eee4651a496270fc4c4486b28fc","node-v17.3.0-linux-arm64.tar.gz":"6f236f47fc68fa535bd0f769d9e12767a6b5251875aea2632c227ca55d1ab7ae","node-v17.3.0-linux-arm64.tar.xz":"ad298da8144635a7ae470b973bddca4270e5a3e5cb919991c367b6e4ea5aa5a9","node-v17.3.0-linux-armv7l.tar.gz":"f92c17fc61af2a47a9b9e42b8e795abfbe18a1fa4e51de52d7362cae74ad487d","node-v17.3.0-linux-armv7l.tar.xz":"660e89b1cf388493a9c00e7720b4bfafa903db12d00481ddae9edf22e950b728","node-v17.3.0-linux-ppc64le.tar.gz":"7161e93479e3df1b18f2fb75b36ef75fd1cbdf2cc610262f510531ef731d0050","node-v17.3.0-linux-ppc64le.tar.xz":"810b3e203bc1d450e543f7c945a136acb7e2f16152839e6f8cf87b4f1ee8c3bb","node-v17.3.0-linux-s390x.tar.gz":"de1b0007f4d46e786f2583b7312e3262820e6535bc16b45da57de65a8472e824","node-v17.3.0-linux-s390x.tar.xz":"10f1da9e679232797e273ca15c6205b86b438eccfceb56f41951af63239cdf76","node-v17.3.0-linux-x64.tar.gz":"479fb0b4b6405fb7240376187e2823cf384635a4998bdbaddc3ea826b63c8c74","node-v17.3.0-linux-x64.tar.xz":"b54b4b7d0732f2dbad9c13f5b909411cde3cc9989bfdeb7557c400e4c93fe6ee","node-v17.3.0.pkg":"f960b616eace93d171a0d15e67c62116aa3c6100eb6266046774cc478487b9d9","node-v17.3.0.tar.gz":"2914a3f0dc02ec6046f81ff12e1fb1fcf2b346b6b50e2c944440fdd165efd3ff","node-v17.3.0.tar.xz":"e4e4c4e64854698f2590144a177bcc7e7c0befb52020288fdae5c0da0d015d03","node-v17.3.0-win-x64.7z":"8876df18c5327e495f6dc4e576c66885c85ec77438386921bc93589788178b18","node-v17.3.0-win-x64.zip":"a7a1d01ca796aa48f3690f1637bf4677dab81cd8608c082e325ebf575d5f832f","node-v17.3.0-win-x86.7z":"62c94ff583c9e2b267f839bd24893bb2a3ee090547658be003e0ba11047d593b","node-v17.3.0-win-x86.zip":"8e766aca83e5a7d01faeb57121f4af4963726b0e8a3f70ff3eeb51493c61ba96","node-v17.3.0-x64.msi":"a2480ad99c7d02a67c71cb462adbb4dad0a2c3884c7fea2ac2da543be18661a6","node-v17.3.0-x86.msi":"5b3b8acff16964add6b24c408060430edf7c2060408568e4286f7dc758cf8cb6","win-x64/node.exe":"9f0b2a11ed3a956a773f4072e40c05645445cbd100d71c30737656159f0e5e42","win-x64/node.lib":"281c2c43920b76ee23c32f110917b50b92977b15842dceada2ed84d7a29e8d34","win-x64/node_pdb.7z":"484ab403a7743cf8e2d04e8e1cc0e1b419e48b601402e01c248a386549c847d8","win-x64/node_pdb.zip":"074124c6ccbc5ceed67c0f7a4091d2e72fb236a6d1a27cb7aaca950e4215ccdc","win-x86/node.exe":"1e4d4bdc1855e032af72080e3390a19d637a85058b52f94d7918b33f0c8ad0db","win-x86/node.lib":"9d79fc5845cf0e8602ea59057639cf2b3731058eb9ada1b8c3bd52638732f4d7","win-x86/node_pdb.7z":"59680a579e30520af180b9ea543ab854b485e287520b7c7b01abef3b1085eb8f","win-x86/node_pdb.zip":"5b5a3f76e247c52c005757935f8360a7d4766134ff7fb858c858567b5785fee3"}
npm ERR! gyp verb download contents checksum {"node-v17.3.0-headers.tar.gz":"9cb2ac1e9a3e7df31269699e02dcc55069cd1f27fd0417650fb95acf8f3e7a22"}
npm ERR! gyp verb validating download checksum for node-v17.3.0-headers.tar.gz (9cb2ac1e9a3e7df31269699e02dcc55069cd1f27fd0417650fb95acf8f3e7a22 == 9cb2ac1e9a3e7df31269699e02dcc55069cd1f27fd0417650fb95acf8f3e7a22)
npm ERR! gyp verb get node dir target node version installed: 17.3.0
npm ERR! gyp verb build dir attempting to create "build" dir: /app/node_modules/node-sass/build
npm ERR! gyp verb build dir "build" dir needed to be created? /app/node_modules/node-sass/build
npm ERR! gyp verb build/config.gypi creating config file
npm ERR! gyp verb build/config.gypi writing out config file: /app/node_modules/node-sass/build/config.gypi
npm ERR! (node:78) [DEP0150] DeprecationWarning: Setting process.config is deprecated. In the future the property will be read-only.
npm ERR! (Use `node --trace-deprecation ...` to show where the warning was created)
npm ERR! gyp verb config.gypi checking for gypi file: /app/node_modules/node-sass/config.gypi
npm ERR! gyp verb common.gypi checking for gypi file: /app/node_modules/node-sass/common.gypi
npm ERR! gyp verb gyp gyp format was not specified; forcing "make"
npm ERR! gyp info spawn /usr/bin/python2
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   '/app/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args   'binding.gyp',
npm ERR! gyp info spawn args   '-f',
npm ERR! gyp info spawn args   'make',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/app/node_modules/node-sass/build/config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/app/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/root/.node-gyp/17.3.0/include/node/common.gypi',
npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
npm ERR! gyp info spawn args   '-Dvisibility=default',
npm ERR! gyp info spawn args   '-Dnode_root_dir=/root/.node-gyp/17.3.0',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/app/node_modules/node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=/root/.node-gyp/17.3.0/<(target_arch)/node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=/app/node_modules/node-sass',
npm ERR! gyp info spawn args   '-Dnode_engine=v8',
npm ERR! gyp info spawn args   '--depth=.',
npm ERR! gyp info spawn args   '--no-parallel',
npm ERR! gyp info spawn args   '--generator-output',
npm ERR! gyp info spawn args   'build',
npm ERR! gyp info spawn args   '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp verb command build []
npm ERR! gyp verb build type Release
npm ERR! gyp verb architecture x64
npm ERR! gyp verb node dev dir /root/.node-gyp/17.3.0
npm ERR! gyp verb `which` succeeded for `make` /usr/bin/make
npm ERR! gyp info spawn make
npm ERR! gyp info spawn args [ 'V=1', 'BUILDTYPE=Release', '-C', 'build' ]
npm ERR! ../src/libsass/src/cencode.c: In function 'base64_encode_block':
npm ERR! ../src/libsass/src/cencode.c:48:11: warning: this statement may fall through [-Wimplicit-fallthrough=]
npm ERR!     result = (fragment & 0x003) << 4;
npm ERR!     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
npm ERR! ../src/libsass/src/cencode.c:52:2: note: here
npm ERR!   case step_B:
npm ERR!   ^~~~
npm ERR! ../src/libsass/src/cencode.c:62:11: warning: this statement may fall through [-Wimplicit-fallthrough=]
npm ERR!     result = (fragment & 0x00f) << 2;
npm ERR!     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
npm ERR! ../src/libsass/src/cencode.c:66:2: note: here
npm ERR!   case step_C:
npm ERR!   ^~~~
npm ERR! ../src/libsass/src/functions.cpp: In function 'void Sass::Functions::handle_utf8_error(const Sass::ParserState&, Sass::Backtraces)':
npm ERR! ../src/libsass/src/functions.cpp:110:20: warning: catching polymorphic type 'class utf8::invalid_code_point' by value [-Wcatch-value=]
npm ERR!        catch (utf8::invalid_code_point) {
npm ERR!                     ^~~~~~~~~~~~~~~~~~
npm ERR! ../src/libsass/src/functions.cpp:114:20: warning: catching polymorphic type 'class utf8::not_enough_room' by value [-Wcatch-value=]
npm ERR!        catch (utf8::not_enough_room) {
npm ERR!                     ^~~~~~~~~~~~~~~
npm ERR! ../src/libsass/src/functions.cpp:118:20: warning: catching polymorphic type 'class utf8::invalid_utf8' by value [-Wcatch-value=]
npm ERR!        catch (utf8::invalid_utf8) {
npm ERR!                     ^~~~~~~~~~~~
npm ERR! ../src/libsass/src/json.cpp: In function 'char* json_encode_string(const char*)':
npm ERR! ../src/libsass/src/json.cpp:405:15: warning: catching polymorphic type 'class std::exception' by value [-Wcatch-value=]
npm ERR!    catch (std::exception) {
npm ERR!                ^~~~~~~~~
npm ERR! ../src/libsass/src/json.cpp: In function 'char* json_stringify(const JsonNode*, const char*)':
npm ERR! ../src/libsass/src/json.cpp:424:15: warning: catching polymorphic type 'class std::exception' by value [-Wcatch-value=]
npm ERR!    catch (std::exception) {
npm ERR!                ^~~~~~~~~
npm ERR! In file included from /root/.node-gyp/17.3.0/include/node/v8-local-handle.h:12,
npm ERR!                  from /root/.node-gyp/17.3.0/include/node/v8-array-buffer.h:12,
npm ERR!                  from /root/.node-gyp/17.3.0/include/node/v8.h:25,
npm ERR!                  from /root/.node-gyp/17.3.0/include/node/node.h:63,
npm ERR!                  from ../../nan/nan.h:58,
npm ERR!                  from ../src/binding.cpp:1:
npm ERR! /root/.node-gyp/17.3.0/include/node/v8-internal.h: In function 'void v8::internal::PerformCastCheck(T*)':
npm ERR! /root/.node-gyp/17.3.0/include/node/v8-internal.h:563:38: error: 'remove_cv_t' is not a member of 'std'
npm ERR!              !std::is_same<Data, std::remove_cv_t<T>>::value>::Perform(data);
npm ERR!                                       ^~~~~~~~~~~
npm ERR! /root/.node-gyp/17.3.0/include/node/v8-internal.h:563:38: note: suggested alternative: 'remove_cv'
npm ERR!              !std::is_same<Data, std::remove_cv_t<T>>::value>::Perform(data);
npm ERR!                                       ^~~~~~~~~~~
npm ERR!                                       remove_cv
npm ERR! /root/.node-gyp/17.3.0/include/node/v8-internal.h:563:38: error: 'remove_cv_t' is not a member of 'std'
npm ERR! /root/.node-gyp/17.3.0/include/node/v8-internal.h:563:38: note: suggested alternative: 'remove_cv'
npm ERR!              !std::is_same<Data, std::remove_cv_t<T>>::value>::Perform(data);
npm ERR!                                       ^~~~~~~~~~~
npm ERR!                                       remove_cv
npm ERR! /root/.node-gyp/17.3.0/include/node/v8-internal.h:563:50: error: template argument 2 is invalid
npm ERR!              !std::is_same<Data, std::remove_cv_t<T>>::value>::Perform(data);
npm ERR!                                                   ^
npm ERR! /root/.node-gyp/17.3.0/include/node/v8-internal.h:563:63: error: '::Perform' has not been declared
npm ERR!              !std::is_same<Data, std::remove_cv_t<T>>::value>::Perform(data);
npm ERR!                                                                ^~~~~~~
npm ERR! /root/.node-gyp/17.3.0/include/node/v8-internal.h:563:63: note: suggested alternative: 'herror'
npm ERR!              !std::is_same<Data, std::remove_cv_t<T>>::value>::Perform(data);
npm ERR!                                                                ^~~~~~~
npm ERR!                                                                herror
npm ERR! ../src/binding.cpp: In function 'Nan::NAN_METHOD_RETURN_TYPE render(Nan::NAN_METHOD_ARGS_TYPE)':
npm ERR! ../src/binding.cpp:284:98: warning: cast between incompatible function types from 'void (*)(uv_work_t*)' {aka 'void (*)(uv_work_s*)'} to 'uv_after_work_cb' {aka 'void (*)(uv_work_s*, int)'} [-Wcast-function-type]
npm ERR!      int status = uv_queue_work(uv_default_loop(), &ctx_w->request, compile_it, (uv_after_work_cb)MakeCallback);
npm ERR!                                                                                                   ^~~~~~~~~~~~
npm ERR! ../src/binding.cpp: In function 'Nan::NAN_METHOD_RETURN_TYPE render_file(Nan::NAN_METHOD_ARGS_TYPE)':
npm ERR! ../src/binding.cpp:320:98: warning: cast between incompatible function types from 'void (*)(uv_work_t*)' {aka 'void (*)(uv_work_s*)'} to 'uv_after_work_cb' {aka 'void (*)(uv_work_s*, int)'} [-Wcast-function-type]
npm ERR!      int status = uv_queue_work(uv_default_loop(), &ctx_w->request, compile_it, (uv_after_work_cb)MakeCallback);
npm ERR!                                                                                                   ^~~~~~~~~~~~
npm ERR! In file included from ../../nan/nan.h:58,
npm ERR!                  from ../src/binding.cpp:1:
npm ERR! ../src/binding.cpp: At global scope:
npm ERR! /root/.node-gyp/17.3.0/include/node/node.h:843:43: warning: cast between incompatible function types from 'void (*)(Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE)' {aka 'void (*)(v8::Local<v8::Object>)'} to 'node::addon_register_func' {aka 'void (*)(v8::Local<v8::Object>, v8::Local<v8::Value>, void*)'} [-Wcast-function-type]
npm ERR!        (node::addon_register_func) (regfunc),                          \
npm ERR!                                            ^
npm ERR! /root/.node-gyp/17.3.0/include/node/node.h:877:3: note: in expansion of macro 'NODE_MODULE_X'
npm ERR!    NODE_MODULE_X(modname, regfunc, NULL, 0)  // NOLINT (readability/null_usage)
npm ERR!    ^~~~~~~~~~~~~
npm ERR! ../src/binding.cpp:358:1: note: in expansion of macro 'NODE_MODULE'
npm ERR!  NODE_MODULE(binding, RegisterModule);
npm ERR!  ^~~~~~~~~~~
npm ERR! make: *** [binding.target.mk:133: Release/obj.target/binding/src/binding.o] Error 1
npm ERR! gyp ERR! build error 
npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2
npm ERR! gyp ERR! stack     at ChildProcess.onExit (/app/node_modules/node-gyp/lib/build.js:262:23)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:390:28)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
npm ERR! gyp ERR! System Linux 5.10.84-1-MANJARO
npm ERR! gyp ERR! command "/usr/local/bin/node" "/app/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
npm ERR! gyp ERR! cwd /app/node_modules/node-sass
npm ERR! gyp ERR! node -v v17.3.0
npm ERR! gyp ERR! node-gyp -v v3.8.0
npm ERR! gyp ERR! not ok 
npm ERR! Build failed with error code: 1

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2022-01-09T19_05_59_458Z-debug-0.log

好吧,这很愚蠢。但是,是的,要为其他 npm 新手阅读这些错误消息:

npm WARN EBADENGINE   package: '@casl/react@2.1.1',
npm WARN EBADENGINE   required: { npm: '^6.0.0' },
npm WARN EBADENGINE   current: { node: 'v17.3.0', npm: '8.3.0' }

这基本上意味着 casl/react(无论做什么)最多接受 npm 6.0.0,但我是 运行 节点 17.x 和 npm 8.x。它对此犹豫不决。

因为Docker很棒,我可以这样做:

FROM node:14-buster

WORKDIR /app

ENV PATH /app/node_modules/.bin:$PATH

# install app dependencies
COPY package.json ./

COPY . ./
RUN mkdir node_modules/.cache && chmod -R 777 node_modules/.cache

# start app
CMD ["npm", "start"]

然后 运行 很好。