NodeJS TurboRepo启动Web服务器,然后立即成功存在

alen0pnh  于 2023-10-17  发布在  Node.js
关注(0)|答案(1)|浏览(157)

我用pnpm设置了turborepo,我试图用这个命令启动我的一个客户端的react前端:npx turbo run start --filter=testclient
下面是这个命令的输出:

• Packages in scope: testclient
• Running start in 1 packages
testclient:start: cache bypass, force executing 4ef91202eb77e2b8
testclient:start: 
testclient:start: > [email protected] start /Users/me/frontend/frontend-core/clients/testclient
testclient:start: > node node_modules/react-scripts/bin/react-scripts.js --max-old-space-size=4096 start
testclient:start: 
testclient:start: ℹ 「wds」: Project is running at http://192.168.0.54/
testclient:start: ℹ 「wds」: webpack output is served from 
testclient:start: ℹ 「wds」: Content not from webpack is served from /Users/me/frontend/frontend-core/clients/testclient/public
testclient:start: ℹ 「wds」: 404s will fallback to /
testclient:start: Starting the development server...
testclient:start: 

 Tasks:    1 successful, 1 total
Cached:    0 cached, 1 total
  Time:    2.339s

正如你所看到的,turbo启动开发服务器没有问题,但它立即存在,而不是保持服务器运行。
在我的/turbo.json中,我在这里指定了start

{
  "$schema": "https://turborepo.org/schema.json",
  "pipeline": {
    "start": { "cache": false },
    ...

/pnpm-workspace.yaml

packages:
  - 'packages/*'
  - 'clients/**'
  - '!**/tests/**'

/package.json

{
  "private": true,
  "workspaces": [
    "clients/*",
    "packages/*"
  ],
  "scripts": {
    [ no "start" script here as only packages in '/clients' have that ]
    ...

/clients/testclient/package.json包含“start”脚本:

{
  "name": "testclient",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-scripts/bin/react-scripts.js --max-old-space-size=4096 start",
    ...

我可以通过运行npx turbo run build --filter=testclient来毫无问题地构建Turborepo
奇怪的是,我可以通过运行npm start --prefix=clients/testclient来启动dev服务器,但是输出看起来不同:

Compiled with warnings.

/Users/me/frontend/frontend-core/packages/frontend-core/dist/frontend-core.css (/Users/me/frontend/frontend-core/node_modules/.pnpm/[email protected][email protected]/node_modules/css-loader/dist/cjs.js??ref--6-oneOf-3-1!/Users/me/frontend/frontend-core/node_modules/.pnpm/[email protected]/node_modules/postcss-loader/src??postcss!/Users/me/frontend/frontend-core/packages/frontend-core/dist/frontend-core.css)
Warning

(14:63200) end value has mixed support, consider using flex-end instead

Search for the keywords to learn more about each warning.
To ignore, add // eslint-disable-next-line to the line before.

你知道为什么turborepo在服务器启动后就存在了,把服务器也一起关了吗?

zysjyyx4

zysjyyx41#

一个可能的解释是服务器实际上在启动时崩溃。如果将cd插入/clients/testclient并从该文件夹运行pnpm start,会发生什么?
您也可以尝试将persistent: true添加到start管道中(尽管根据文档,这不会有任何影响)。

相关问题