内容目录
原因
一台老旧的centos6.5 需要npm打包
原来的版本8.2.1太老了
安装18.20.8LTS报错
[root@localhost node18]# node -v
node: /lib64/libm.so.6: version `GLIBC_2.27' not found (required by node)
node: /lib64/libc.so.6: version `GLIBC_2.25' not found (required by node)
node: /lib64/libc.so.6: version `GLIBC_2.28' not found (required by node)
node: /usr/lib/libstdc++.so.6: version `CXXABI_1.3.9' not found (required by node)
node: /usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by node)
node: /usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by node)
老服务器GLIBC不可轻动,往下找版本,最后14.21.3跑通
下载安装打包
下载地址
https://nodejs.org/en/download
复制下载地址
安装命令
cd /usr/local
wget -O node-v14.21.3-linux-x64.tar.xz https://nodejs.org/dist/v14.21.3/node-v14.21.3-linux-x64.tar.xz
tar -xvf node-v14.21.3-linux-x64.tar.xz
mv node-v14.21.3-linux-x64 node
echo 'export PATH=/usr/local/node/bin:$PATH' >>/etc/profile
source /etc/profile
[root@localhost dist]# node -v
v14.21.3
[root@localhost dist]# npm -v
6.14.18
打包
虽然还是有81个问题
found 85 vulnerabilities (4 low, 48 moderate, 30 high, 3 critical)
但是起码打包成功
[root@localhost gladmin-ui]# npm install --unsafe-perm
npm WARN read-shrinkwrap This version of npm is compatible with lockfileVersion@1, but package-lock.json was generated for lockfileVersion@2. I'll try to do my best with it!
> node-sass@4.14.1 install /tmp/gladmin-ui/node_modules/node-sass
> node scripts/install.js
Cached binary found at /root/.npm/node-sass/4.14.1/linux-x64-83_binding.node
> core-js@2.6.12 postinstall /tmp/gladmin-ui/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"
Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!
The project needs your help! Please consider supporting of core-js on Open Collective or Patreon:
> https://opencollective.com/core-js
> https://www.patreon.com/zloirock
Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)
> core-js-pure@3.41.0 postinstall /tmp/gladmin-ui/node_modules/core-js-pure
> node -e "try{require('./postinstall')}catch(e){}"
Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!
The project needs your help! Please consider supporting core-js:
> https://opencollective.com/core-js
> https://patreon.com/zloirock
> https://boosty.to/zloirock
> bitcoin: bc1qlea7544qtsmj2rayg0lthvza9fau63ux0fstcz
I highly recommend reading this: https://github.com/zloirock/core-js/blob/master/docs/2023-02-14-so-whats-next.md
> ejs@2.7.4 postinstall /tmp/gladmin-ui/node_modules/ejs
> node ./postinstall.js
Thank you for installing EJS: built with the Jake JavaScript build tool (https://jakejs.com/)
> node-sass@4.14.1 postinstall /tmp/gladmin-ui/node_modules/node-sass
> node scripts/build.js
Binary found at /tmp/gladmin-ui/node_modules/node-sass/vendor/linux-x64-83/binding.node
Testing binary
Binary is fine
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/webpack-dev-server/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/watchpack-chokidar2/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.3.3 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
updated 1420 packages and audited 1428 packages in 20.917s
142 packages are looking for funding
run `npm fund` for details
found 85 vulnerabilities (4 low, 48 moderate, 30 high, 3 critical)
run `npm audit fix` to fix them, or `npm audit` for details
[root@localhost gladmin-ui]# npm run build
> gladmin-ui@1.0.0 build /tmp/gladmin-ui
> vue-cli-service build
⠇ Building for production...
WARNING Compiled with 2 warnings 02:53:10
warning
asset size limit: The following asset(s) exceed the recommended size limit (244 KiB).
This can impact web performance.
Assets:
js/chunk-84cb8672.e9a8a49a.js (797 KiB)
css/chunk-vendors.37a49782.css (312 KiB)
js/chunk-vendors.f0cd405c.js (4.02 MiB)
img/logo.png (892 KiB)
cdn/xlsx/0.14.1/xlsx.full.min.js (1.26 MiB)
warning
entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (244 KiB). This can impact web performance.
Entrypoints:
app (4.39 MiB)
css/chunk-vendors.37a49782.css
js/chunk-vendors.f0cd405c.js
css/app.eabfe730.css
js/app.eba467bd.js
File Size Gzipped
dist/cdn/xlsx/0.14.1/xlsx.full.min.js 1292.31 KiB 358.50 KiB
dist/cdn/moment/2.9.0/moment.min.js 57.48 KiB 18.17 KiB
dist/cdn/file/FileSaver.min.js 2.80 KiB 1.28 KiB
dist/js/chunk-vendors.f0cd405c.js 4121.45 KiB 1130.06 KiB
dist/js/chunk-84cb8672.e9a8a49a.js 796.77 KiB 174.08 KiB
dist/js/app.eba467bd.js 49.13 KiB 14.27 KiB
dist/js/page.8ea9caca.js 16.68 KiB 4.02 KiB
dist/js/chunk-6ea2b370.c8cb8469.js 14.86 KiB 3.44 KiB
dist/js/chunk-3ffe4060.caa3604d.js 12.72 KiB 3.22 KiB
dist/cdn/store/1.3.20/store.js 6.79 KiB 2.24 KiB
dist/js/views.018d5ba2.js 5.20 KiB 1.90 KiB
dist/js/chunk-2d0e4caf.196bdc56.js 0.27 KiB 0.22 KiB
dist/css/chunk-vendors.37a49782.css 311.62 KiB 47.67 KiB
dist/cdn/animate/3.5.2/animate.css 51.55 KiB 3.87 KiB
dist/css/chunk-84cb8672.5a2dcdce.css 35.46 KiB 6.99 KiB
dist/css/app.eabfe730.css 13.17 KiB 3.24 KiB
dist/css/page.25a97cd1.css 9.10 KiB 1.60 KiB
dist/cdn/avue/avue.css 0.78 KiB 0.33 KiB
Images and other types of assets omitted.
DONE Build complete. The dist directory is ready to be deployed.
INFO Check out deployment instructions at https://cli.vuejs.org/guide/deployment.html
附录
其他版本测试17.9.1 16.20.2 15.14.0也都可以安装成功,版本号也成功显示,但是项目打包npm install 依赖太多,某些依赖严重报错无法打包成功
如果你的项目依赖少不触发严重错误只是警告,可以使用这些版本
部分报错日志
15.14.0
Building for production...
ERROR Failed to compile with 2 errors 上午2:51:33
error in ./src/styles/common.scss
Error: /usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by /tmp/gladmin-ui/node_modules/node-sass/vendor/linux-x64-88/binding.node)
16.20.2
npm ERR! In file included from ../../nan/nan.h:62,
npm ERR! from ../src/binding.cpp:1:
npm ERR! ../src/binding.cpp: 在全局域:
npm ERR! /root/.node-gyp/16.20.2/include/node/node.h:887:7: 警告: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! 887 | (node::addon_register_func) (regfunc), \
npm ERR! | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
npm ERR! /root/.node-gyp/16.20.2/include/node/node.h:921:3: 附注:in expansion of macro ‘NODE_MODULE_X’
npm ERR! 921 | NODE_MODULE_X(modname, regfunc, NULL, 0) // NOLINT (readability/null_usage)
npm ERR! | ^~~~~~~~~~~~~
npm ERR! ../src/binding.cpp:358:1: 附注:in expansion of macro ‘NODE_MODULE’
npm ERR! 358 | NODE_MODULE(binding, RegisterModule);
npm ERR! | ^~~~~~~~~~~
npm ERR! make: *** [Release/obj.target/binding/src/binding.o] 错误 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 (/tmp/gladmin-ui/node_modules/node-gyp/lib/build.js:262:23)
npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:513:28)
npm ERR! gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:293:12)
npm ERR! gyp ERR! System Linux 2.6.32-431.el6.x86_64
npm ERR! gyp ERR! command "/usr/local/node/bin/node" "/tmp/gladmin-ui/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
npm ERR! gyp ERR! cwd /tmp/gladmin-ui/node_modules/node-sass
npm ERR! gyp ERR! node -v v16.20.2
npm ERR! gyp ERR! node-gyp -v v3.8.0
npm ERR! gyp ERR! not ok
npm ERR! Build failed with error code: 1
17.9.1
npm ERR! /root/.node-gyp/17.9.1/include/node/v8-internal.h:563:38: 错误:‘remove_cv_t’ is not a member of ‘std’; did you mean ‘remove_cv’?
npm ERR! 563 | !std::is_same<Data, std::remove_cv_t<T>>::value>::Perform(data);
npm ERR! | ^~~~~~~~~~~
npm ERR! | remove_cv
npm ERR! /root/.node-gyp/17.9.1/include/node/v8-internal.h:563:50: 错误:模板第 2 个参数无效
npm ERR! 563 | !std::is_same<Data, std::remove_cv_t<T>>::value>::Perform(data);
npm ERR! | ^
npm ERR! /root/.node-gyp/17.9.1/include/node/v8-internal.h:563:63: 错误:‘::Perform’未被声明
npm ERR! 563 | !std::is_same<Data, std::remove_cv_t<T>>::value>::Perform(data);
npm ERR! | ^~~~~~~
npm ERR! ../src/binding.cpp: 在函数‘Nan::NAN_METHOD_RETURN_TYPE render(Nan::NAN_METHOD_ARGS_TYPE)’中:
npm ERR! ../src/binding.cpp:284:80: 警告: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! 284 | 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: 在函数‘Nan::NAN_METHOD_RETURN_TYPE render_file(Nan::NAN_METHOD_ARGS_TYPE)’中:
npm ERR! ../src/binding.cpp:320:80: 警告: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! 320 | 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:62,
npm ERR! from ../src/binding.cpp:1:
npm ERR! ../src/binding.cpp: 在全局域:
npm ERR! /root/.node-gyp/17.9.1/include/node/node.h:848:7: 警告: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! 848 | (node::addon_register_func) (regfunc), \
npm ERR! | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
npm ERR! /root/.node-gyp/17.9.1/include/node/node.h:882:3: 附注:in expansion of macro ‘NODE_MODULE_X’
npm ERR! 882 | NODE_MODULE_X(modname, regfunc, NULL, 0) // NOLINT (readability/null_usage)
npm ERR! | ^~~~~~~~~~~~~
npm ERR! ../src/binding.cpp:358:1: 附注:in expansion of macro ‘NODE_MODULE’
npm ERR! 358 | NODE_MODULE(binding, RegisterModule);
npm ERR! | ^~~~~~~~~~~
npm ERR! make: *** [Release/obj.target/binding/src/binding.o] 错误 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 (/tmp/gladmin-ui/node_modules/node-gyp/lib/build.js:262:23)
npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:527:28)
npm ERR! gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
npm ERR! gyp ERR! System Linux 2.6.32-431.el6.x86_64
npm ERR! gyp ERR! command "/usr/local/node/bin/node" "/tmp/gladmin-ui/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
npm ERR! gyp ERR! cwd /tmp/gladmin-ui/node_modules/node-sass
npm ERR! gyp ERR! node -v v17.9.1
npm ERR! gyp ERR! node-gyp -v v3.8.0
npm ERR! gyp ERR! not ok
npm ERR! Build failed with error code: 1
近期评论