alibaba / rax

🐰 Rax is a progressive framework for building universal application. https://rax.js.org
Other
8k stars 627 forks source link

[Question]如何解决`Cannot find target @builder/swc native module!` #2352

Open xmsz opened 2 years ago

xmsz commented 2 years ago

背景


9320 verbose Linux 3.10.0-693.el7.x86_64
9321 verbose argv "/usr/bin/node" "/usr/bin/npm" "i"
9322 verbose node v16.14.1
9323 verbose npm  v8.5.0

npm run build
[root@VM-0-14-centos test]# npm run build

> @rax-materials/scaffolds-app-ts@0.1.0 build
> rax-app build

rax-app 3.8.18
JSX+ enabled, documentation: https://rax.js.org/docs/guide/component

✖ Web
  Compiled with some errors in 7.11s

info WEBPACK web:
info WEBPACK   assets by status 71.6 KiB [cached] 2 assets
info WEBPACK   web (webpack 5.67.0) compiled with 1 error in 7116 ms
ERR! Error: Cannot find target @builder/swc native module!
ERR! webpack compile error 
Error: webpack compile error
    at /var/lib/jenkins/workspace/test/node_modules/build-scripts/lib/service/build.js:81:28
    at /var/lib/jenkins/workspace/test/node_modules/@builder/pack/deps/webpack/bundle5.js:73772:14
    at processQueueWorker (/var/lib/jenkins/workspace/test/node_modules/@builder/pack/deps/webpack/bundle5.js:73709:6)
    at processTicksAndRejections (node:internal/process/task_queues:78:11)
``
xmsz commented 2 years ago

还有运行npm run start 会卡住


● Web █████████████████████████ building (28%) 1/3 entries 58/76 dependencies 21/40 modules 15 active 
 babel-loader › rax-platform-loader › node_modules/html-entities/lib/named-references.js

(node:6671) [DEP_WEBPACK_DEV_SERVER_ON_BEFORE_SETUP_MIDDLEWARE] DeprecationWarning: 'onBeforeSetupMiddleware' option is deprecated. Please use the
 'setupMiddlewares' option.
(Use `node --trace-deprecation ...` to show where the warning was created)

<--- Last few GCs --->

[6671:0x87f3c0]    21324 ms: Scavenge 911.2 (932.9) -> 909.4 (933.4) MB, 1.1 / 0.0 ms  (average mu = 0.237, current mu = 0.207) allocation failure 
[6671:0x87f3c0]    21327 ms: Scavenge 911.7 (933.4) -> 909.9 (933.9) MB, 1.3 / 0.0 ms  (average mu = 0.237, current mu = 0.207) allocation failure 
[6671:0x87f3c0]    21329 ms: Scavenge 912.0 (933.9) -> 910.1 (937.9) MB, 1.4 / 0.0 ms  (average mu = 0.237, current mu = 0.207) allocation failure 

<--- JS stacktrace --->

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
^C
SoloJiang commented 2 years ago

你开启了 swc 么,可以提供下你云构建的系统环境,os 和 cpu 架构

SoloJiang commented 2 years ago

第二个卡住是因为 babel 全量编译了 node_modules,https://rax.js.org/docs/guide/build-config#compileDependencies 可以通过这个配置项按需编译

xmsz commented 2 years ago

os 和 cpu 架构

Linux version 3.10.0-693.el7.x86_64 (builder@kbuilder.dev.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC) ) #1 SMP Tue Aug 22 21:09:27 UTC 2017 CentOS Linux release 7.4.1708 (Core) x86_64 在腾讯云上随便搞得2g服务器 + centos7.4 + jenkins

然后项目是默认创建的 没有任何改动

xmsz commented 2 years ago

然后这是临时jenkins

http://175.27.160.203:8080/job/test/ admin e187c6554cea4638b59bd7dae2f35a18

可以先拿来测试

http://175.27.160.203:8080/job/test/8/console

SoloJiang commented 2 years ago

测试链接好像都打不开

xmsz commented 2 years ago

测试链接好像都打不开

我重开一个

http://175.27.154.116:8080/ admin e187c6554cea4638b59bd7dae2f35a18

xmsz commented 2 years ago

http://175.27.154.116:8080/job/test/2/console

Clago commented 1 year ago

解决了吗,我服务器上编译也是这个错误,linux环境

Tanelmer commented 1 year ago

你开启了 swc 么,可以提供下你云构建的系统环境,os 和 cpu 架构

var triples = triples_1.platformArchTriples[PlatformName][ArchName]; console.log(triples); [ { platform: 'linux', arch: 'x64', abi: 'gnu', platformArchABI: 'linux-x64-gnu', raw: 'x86_64-unknown-linux-gnu' }, { platform: 'linux', arch: 'x64', abi: 'gnux32', platformArchABI: 'linux-x64-gnux32', raw: 'x86_64-unknown-linux-gnux32' }, { platform: 'linux', arch: 'x64', abi: 'musl', platformArchABI: 'linux-x64-musl', raw: 'x86_64-unknown-linux-musl' } ]

ipengkai commented 5 months ago

解决了吗?linux/arm64平台上打包时遇到了同样的问题。