gpt4 book ai didi

node.js - Lerna 构建在远程失败 - 内部包的符号链接(symbolic link)很糟糕

转载 作者:行者123 更新时间:2023-12-05 06:00:34 29 4
gpt4 key购买 nike

我有一个使用 lerna 创建的 monorepo 项目。
我正在尝试创建一个 CI 流程来测试我的存储库安装并在远程环境中构建操作。
点击 lerna bootstrap 安装所有依赖包后,我在根文件夹上使用 lerna run build --stream 调用 lerna run build我存储库中的每个子包。
此流程在我的本地机器上运行良好,但无法使用 travis-ci 构建。

到目前为止的结论:

  1. 问题可能与travis-ci 服务操作系统 无关,因为在 GCP 上的两个 Ubuntu VM 实例上都出现了相同的行为,我正在尝试运行该流程在配置为 macOS 机器的 travis-ci 服务器上。
  2. 引导标志 --no-ci--force-local 都没有改变任何东西。
  3. 导航到 ~/sqpoc/node_modules/@superquery/components/dist 表明构建文件已正确创建,这意味着问题可能与失败的内部 lerna 符号链接(symbolic link)流有关 在规定的环境中。

输出:

$ lerna run build --stream
lerna notice cli v4.0.0
lerna info Executing command in 4 packages: "yarn run build"
@superquery/components: $ node ./scripts/build.ts
@superquery/greeter: $ tsc -p tsconfig.release.json && webpack
@superquery/superquery: $ react-scripts build
@superquery/superquery: Creating an optimized production build...
@superquery/greeter: asset bundle.js 39.4 KiB [compared for emit] (name: main)
@superquery/greeter: runtime modules 670 bytes 3 modules
@superquery/greeter: cacheable modules 11.5 KiB
@superquery/greeter: ./build/src/main.js 701 bytes [built] [code generated]
@superquery/greeter: ./node_modules/tslib/tslib.es6.js 10.8 KiB [built] [code generated]
@superquery/greeter: webpack 5.37.0 compiled successfully in 3703 ms
@superquery/server: $ tsc -p tsconfig.release.json
@superquery/superquery: Failed to compile.
@superquery/superquery: ./src/App.tsx
@superquery/superquery: Cannot find module: '@superquery/components'. Make sure this package is installed.
@superquery/superquery: You can install this package by running: yarn add @superquery/components.
@superquery/superquery: error Command failed with exit code 1.
@superquery/superquery: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
lerna ERR! yarn run build exited 1 in '@superquery/superquery'
error Command failed with exit code 1.

预期输出:

$ lerna run build --stream
lerna notice cli v4.0.0
lerna info Executing command in 4 packages: "yarn run build"
@superquery/components: $ node ./scripts/build.ts
@superquery/greeter: $ tsc -p tsconfig.release.json && webpack
@superquery/greeter: asset bundle.js 39.4 KiB [compared for emit] (name: main)
@superquery/greeter: runtime modules 670 bytes 3 modules
@superquery/greeter: cacheable modules 11.5 KiB
@superquery/greeter: ./build/src/main.js 701 bytes [built] [code generated]
@superquery/greeter: ./node_modules/tslib/tslib.es6.js 10.8 KiB [built] [code generated]
@superquery/greeter: webpack 5.37.0 compiled successfully in 1521 ms
@superquery/server: $ tsc -p tsconfig.release.json
@superquery/superquery: $ react-scripts build
@superquery/superquery: Creating an optimized production build...
@superquery/superquery: Compiled successfully.
@superquery/superquery: File sizes after gzip:
@superquery/superquery: 119.52 KB build/static/js/2.ea8fed9a.chunk.js
@superquery/superquery: 4.79 KB build/static/js/main.7a35accd.chunk.js
@superquery/superquery: 1.41 KB build/static/js/3.80a7969b.chunk.js
@superquery/superquery: 1.17 KB build/static/js/runtime-main.d48b464c.js
@superquery/superquery: 574 B build/static/css/main.9d5b29c0.chunk.css
@superquery/superquery: The project was built assuming it is hosted at /.
@superquery/superquery: You can control this with the homepage field in your package.json.
@superquery/superquery: The build folder is ready to be deployed.
@superquery/superquery: You may serve it with a static server:
@superquery/superquery: npm install -g serve
@superquery/superquery: serve -s build
@superquery/superquery: Find out more about deployment here:
@superquery/superquery: https://cra.link/deployment
lerna success run Ran npm script 'build' in 4 packages in 35.9s:
lerna success - @superquery/components
lerna success - @superquery/greeter
lerna success - @superquery/server
lerna success - @superquery/superquery
✨ Done in 37.28s.

package.json 文件:

{
"name": "superquery",
"version": "1.0.0",
"author": "***************",
"repository": "https://github.com/doitintl/sqpoc.git",
"main": "index.js",
"license": "MIT",
"private": true,
"workspaces": {
"packages": [
"packages/*"
]
},
"scripts": {
"start": "lerna run start --stream",
"test": "lerna run test --stream",
"test:ci": "lerna run test:ci --stream",
"watch": "lerna run watch --stream",
"storybook": "lerna run storybook --stream",
"production": "lerna run production --stream",
"build": "lerna run build --stream",
"deploy": "lerna run deploy --stream",
"bootstrap": "lerna run rimraf && lerna bootstrap",
"rimraf": "rm -rf node_modules",
"installApp": "yarn rimraf && yarn install && yarn bootstrap",
"dev": "lerna run dev",
"dev-logs": "lerna run dev --parallel",
"dev-module": "lerna run dev --scope",
"e2e": "nightwatch -e chrome,firefox",
"e2e-test": "concurrently -k --success first \"npm run start\" \"npm run e2e\""
},
"devDependencies": {
"chromedriver": "^90.0.0",
"geckodriver": "^1.22.3",
"lerna": "^4.0.0",
"selenium-server": "^3.141.59"
}
}

lerna.json 文件:

{
"useWorkspaces": true,
"npmClient": "yarn",
"version": "1.0.0",
"packages": [
"packages/superquery",
"packages/components"
]
}

使用的技术栈:
Node 14.17.0
npm 6.14.13
nvm 0.37.2
勒纳 4.0.0
yarn 1.22.10

尝试遵循以下链接(以及更多)的建议,这要么是幼稚的,要么与我的问题无关。
Lerna bootstrap does not link local dependencies?
https://github.com/lerna/lerna/issues/1444

最佳答案

更新 lerna.json 文件后解决:

{
"useWorkspaces": true,
"npmClient": "yarn",
"version": "1.0.0"
}

关于node.js - Lerna 构建在远程失败 - 内部包的符号链接(symbolic link)很糟糕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67623140/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com