和平宇宙 2024-02-28 21:25 采纳率: 100%
浏览 7
已结题

本地部署一个javaweb项目

这里有一个开源项目,看怎么本地部署运行,好像没有运行入口 (尽量详细点,本人javaweb不熟~):https://github.com/statelyai/xstate
问了文心一言,知道怎么编译和测试了(yarn test 后一共有4个错误),但没有找到运行入口,真的头疼,难道要全部测试通过才行?


npm install -g corepack
npm install -g typescript
yarn  install
yarn  run build
yarn  test



.
.
.
PASS packages/xstate-solid/test/deepClone.test.ts
FAIL packages/xstate-solid/test/useActorRef.test.tsx
  ● Test suite failed to run

    Jest encountered an unexpected token

    Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax.

    Out of the box Jest supports Babel, which will be used to transform your files into valid JS based on your Babel configuration.

    By default "node_modules" folder is ignored by transformers.

    Here's what you can do:
     • If you are trying to use ECMAScript Modules, see https://jestjs.io/docs/ecmascript-modules for how to enable it.If you are trying to use TypeScript, see https://jestjs.io/docs/getting-started#using-typescript
     • To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
     • If you need a custom transformation specify a "transform" option in your config.
     • If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.

    You'll find more details and examples of these config options in the docs:
    https://jestjs.io/docs/configuration
    For information about custom transformations, see:
    https://jestjs.io/docs/code-transformation

    Details:

    E:\__WorkTable\xstate\node_modules\solid-js\dist\solid.js:1630
    export { $DEVCOMP, $PROXY, $TRACK, DEV, ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, batch, cancelCallback, catchError, children, createComponent, createComputed, createContext, createDeferred, createEffect, createMemo, createReaction, createRenderEffect, createResource, createRoot, createSelector, createSignal, createUniqueId, enableExternalSource, enableHydration, enableScheduling, equalFn, from, getListener, getOwner, indexArray, lazy, mapArray, mergeProps, observable, on, onCleanup, onError, onMount, requestCallback, resetErrorBoundaries, runWithOwner, sharedConfig, splitProps, startTransition, untrack, useContext, useTransition };
    ^^^^^^

    SyntaxError: Unexpected token 'export'

      3 | import { render, fireEvent, screen } from 'solid-testing-library';
      4 | import { useActorRef } from '../src/index.ts';
    > 5 | import { createEffect } from 'solid-js';
        |                                         ^
      6 |
      7 | describe('useActorRef', () => {
      8 |   it('observer should be called with next state', (done) => {

      at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1505:14)
      at Object.require (packages/xstate-solid/test/useActorRef.test.tsx:5:41)

FAIL packages/xstate-solid/test/selector.test.tsx
  ● Test suite failed to run

    Jest encountered an unexpected token

    Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax.

    Out of the box Jest supports Babel, which will be used to transform your files into valid JS based on your Babel configuration.

    By default "node_modules" folder is ignored by transformers.

    Here's what you can do:
     • If you are trying to use ECMAScript Modules, see https://jestjs.io/docs/ecmascript-modules for how to enable it.If you are trying to use TypeScript, see https://jestjs.io/docs/getting-started#using-typescript
     • To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
     • If you need a custom transformation specify a "transform" option in your config.
     • If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.

    You'll find more details and examples of these config options in the docs:
    https://jestjs.io/docs/configuration
    For information about custom transformations, see:
    https://jestjs.io/docs/code-transformation

    Details:

    E:\__WorkTable\xstate\node_modules\solid-js\dist\solid.js:1630
    export { $DEVCOMP, $PROXY, $TRACK, DEV, ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, batch, cancelCallback, catchError, children, createComponent, createComputed, createContext, createDeferred, createEffect, createMemo, createReaction, createRenderEffect, createResource, createRoot, createSelector, createSignal, createUniqueId, enableExternalSource, enableHydration, enableScheduling, equalFn, from, getListener, getOwner, indexArray, lazy, mapArray, mergeProps, observable, on, onCleanup, onError, onMount, requestCallback, resetErrorBoundaries, runWithOwner, sharedConfig, splitProps, startTransition, untrack, useContext, useTransition };
    ^^^^^^

    SyntaxError: Unexpected token 'export'

       9 |   createMachine
      10 | } from 'xstate';
    > 11 | import { useActorRef, useMachine, fromActorRef } from '../src/index.ts';
         |                                                                         ^
      12 | describe('usage of selectors with reactive service state', () => {
      13 |   // TODO: rewrite this test to not use `from()`
      14 |   it.skip('only rerenders for selected values', () => {

      at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1505:14)
      at Object.require (packages/xstate-solid/test/selector.test.tsx:11:73)

FAIL packages/xstate-solid/test/fromActorRef.test.tsx
  ● Test suite failed to run

    Jest encountered an unexpected token

    Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax.

    Out of the box Jest supports Babel, which will be used to transform your files into valid JS based on your Babel configuration.

    By default "node_modules" folder is ignored by transformers.

    Here's what you can do:
     • If you are trying to use ECMAScript Modules, see https://jestjs.io/docs/ecmascript-modules for how to enable it.If you are trying to use TypeScript, see https://jestjs.io/docs/getting-started#using-typescript
     • To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
     • If you need a custom transformation specify a "transform" option in your config.
     • If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.

    You'll find more details and examples of these config options in the docs:
    https://jestjs.io/docs/configuration
    For information about custom transformations, see:
    https://jestjs.io/docs/code-transformation

    Details:

    E:\__WorkTable\xstate\node_modules\solid-js\dist\solid.js:1630
    export { $DEVCOMP, $PROXY, $TRACK, DEV, ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, batch, cancelCallback, catchError, children, createComponent, createComputed, createContext, createDeferred, createEffect, createMemo, createReaction, createRenderEffect, createResource, createRoot, createSelector, createSignal, createUniqueId, enableExternalSource, enableHydration, enableScheduling, equalFn, from, getListener, getOwner, indexArray, lazy, mapArray, mergeProps, observable, on, onCleanup, onError, onMount, requestCallback, resetErrorBoundaries, runWithOwner, sharedConfig, splitProps, startTransition, untrack, useContext, useTransition };
    ^^^^^^

    SyntaxError: Unexpected token 'export'

      21 |   sendParent
      22 | } from 'xstate';
    > 23 | import { fromActorRef, useActor } from '../src';
         |                                                 ^
      24 |
      25 | const createSimpleActor = <T extends unknown>(value: T) =>
      26 |   createActor(fromTransition((s) => s, value));

      at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1505:14)
      at Object.require (packages/xstate-solid/test/fromActorRef.test.tsx:23:49)

FAIL packages/xstate-solid/test/useActor.test.tsx
  ● Test suite failed to run

    Jest encountered an unexpected token

    Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax.

    Out of the box Jest supports Babel, which will be used to transform your files into valid JS based on your Babel configuration.

    By default "node_modules" folder is ignored by transformers.

    Here's what you can do:
     • If you are trying to use ECMAScript Modules, see https://jestjs.io/docs/ecmascript-modules for how to enable it.If you are trying to use TypeScript, see https://jestjs.io/docs/getting-started#using-typescript
     • To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
     • If you need a custom transformation specify a "transform" option in your config.
     • If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.

    You'll find more details and examples of these config options in the docs:
    https://jestjs.io/docs/configuration
    For information about custom transformations, see:
    https://jestjs.io/docs/code-transformation

    Details:

    E:\__WorkTable\xstate\node_modules\solid-js\dist\solid.js:1630
    export { $DEVCOMP, $PROXY, $TRACK, DEV, ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, batch, cancelCallback, catchError, children, createComponent, createComputed, createContext, createDeferred, createEffect, createMemo, createReaction, createRenderEffect, createResource, createRoot, createSelector, createSignal, createUniqueId, enableExternalSource, enableHydration, enableScheduling, equalFn, from, getListener, getOwner, indexArray, lazy, mapArray, mergeProps, observable, on, onCleanup, onError, onMount, requestCallback, resetErrorBoundaries, runWithOwner, sharedConfig, splitProps, startTransition, untrack, useContext, useTransition };
    ^^^^^^

    SyntaxError: Unexpected token 'export'

      22 | } from 'xstate';
      23 | import { fromCallback, fromPromise } from 'xstate/actors';
    > 24 | import { useActor } from '../src';
         |                                   ^
      25 |
      26 | function sleep(ms: number) {
      27 |   return new Promise((resolve) => setTimeout(resolve, ms));

      at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1505:14)
      at Object.require (packages/xstate-solid/test/useActor.test.tsx:24:35)

PASS packages/xstate-vue/test/useActor.test.ts
PASS packages/xstate-vue/test/useMachine.test.ts
PASS packages/xstate-vue/test/useSelector.test.ts
PASS packages/xstate-vue/test/useActorRef.test.ts

Summary of all failing tests
FAIL packages/xstate-solid/test/useActorRef.test.tsx
  ● Test suite failed to run

    Jest encountered an unexpected token

    Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax.

    Out of the box Jest supports Babel, which will be used to transform your files into valid JS based on your Babel configuration.

    By default "node_modules" folder is ignored by transformers.

    Here's what you can do:
     • If you are trying to use ECMAScript Modules, see https://jestjs.io/docs/ecmascript-modules for how to enable it.If you are trying to use TypeScript, see https://jestjs.io/docs/getting-started#using-typescript
     • To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
     • If you need a custom transformation specify a "transform" option in your config.
     • If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.

    You'll find more details and examples of these config options in the docs:
    https://jestjs.io/docs/configuration
    For information about custom transformations, see:
    https://jestjs.io/docs/code-transformation

    Details:

    E:\__WorkTable\xstate\node_modules\solid-js\dist\solid.js:1630
    export { $DEVCOMP, $PROXY, $TRACK, DEV, ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, batch, cancelCallback, catchError, children, createComponent, createComputed, createContext, createDeferred, createEffect, createMemo, createReaction, createRenderEffect, createResource, createRoot, createSelector, createSignal, createUniqueId, enableExternalSource, enableHydration, enableScheduling, equalFn, from, getListener, getOwner, indexArray, lazy, mapArray, mergeProps, observable, on, onCleanup, onError, onMount, requestCallback, resetErrorBoundaries, runWithOwner, sharedConfig, splitProps, startTransition, untrack, useContext, useTransition };
    ^^^^^^

    SyntaxError: Unexpected token 'export'

      3 | import { render, fireEvent, screen } from 'solid-testing-library';
      4 | import { useActorRef } from '../src/index.ts';
    > 5 | import { createEffect } from 'solid-js';
        |                                         ^
      6 |
      7 | describe('useActorRef', () => {
      8 |   it('observer should be called with next state', (done) => {

      at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1505:14)
      at Object.require (packages/xstate-solid/test/useActorRef.test.tsx:5:41)

FAIL packages/xstate-solid/test/selector.test.tsx
  ● Test suite failed to run

    Jest encountered an unexpected token

    Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax.

    Out of the box Jest supports Babel, which will be used to transform your files into valid JS based on your Babel configuration.

    By default "node_modules" folder is ignored by transformers.

    Here's what you can do:
     • If you are trying to use ECMAScript Modules, see https://jestjs.io/docs/ecmascript-modules for how to enable it.If you are trying to use TypeScript, see https://jestjs.io/docs/getting-started#using-typescript
     • To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
     • If you need a custom transformation specify a "transform" option in your config.
     • If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.

    You'll find more details and examples of these config options in the docs:
    https://jestjs.io/docs/configuration
    For information about custom transformations, see:
    https://jestjs.io/docs/code-transformation

    Details:

    E:\__WorkTable\xstate\node_modules\solid-js\dist\solid.js:1630
    export { $DEVCOMP, $PROXY, $TRACK, DEV, ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, batch, cancelCallback, catchError, children, createComponent, createComputed, createContext, createDeferred, createEffect, createMemo, createReaction, createRenderEffect, createResource, createRoot, createSelector, createSignal, createUniqueId, enableExternalSource, enableHydration, enableScheduling, equalFn, from, getListener, getOwner, indexArray, lazy, mapArray, mergeProps, observable, on, onCleanup, onError, onMount, requestCallback, resetErrorBoundaries, runWithOwner, sharedConfig, splitProps, startTransition, untrack, useContext, useTransition };
    ^^^^^^

    SyntaxError: Unexpected token 'export'

       9 |   createMachine
      10 | } from 'xstate';
    > 11 | import { useActorRef, useMachine, fromActorRef } from '../src/index.ts';
         |                                                                         ^
      12 | describe('usage of selectors with reactive service state', () => {
      13 |   // TODO: rewrite this test to not use `from()`
      14 |   it.skip('only rerenders for selected values', () => {

      at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1505:14)
      at Object.require (packages/xstate-solid/test/selector.test.tsx:11:73)

FAIL packages/xstate-solid/test/fromActorRef.test.tsx
  ● Test suite failed to run

    Jest encountered an unexpected token

    Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax.

    Out of the box Jest supports Babel, which will be used to transform your files into valid JS based on your Babel configuration.

    By default "node_modules" folder is ignored by transformers.

    Here's what you can do:
     • If you are trying to use ECMAScript Modules, see https://jestjs.io/docs/ecmascript-modules for how to enable it.If you are trying to use TypeScript, see https://jestjs.io/docs/getting-started#using-typescript
     • To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
     • If you need a custom transformation specify a "transform" option in your config.
     • If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.

    You'll find more details and examples of these config options in the docs:
    https://jestjs.io/docs/configuration
    For information about custom transformations, see:
    https://jestjs.io/docs/code-transformation

    Details:

    E:\__WorkTable\xstate\node_modules\solid-js\dist\solid.js:1630
    export { $DEVCOMP, $PROXY, $TRACK, DEV, ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, batch, cancelCallback, catchError, children, createComponent, createComputed, createContext, createDeferred, createEffect, createMemo, createReaction, createRenderEffect, createResource, createRoot, createSelector, createSignal, createUniqueId, enableExternalSource, enableHydration, enableScheduling, equalFn, from, getListener, getOwner, indexArray, lazy, mapArray, mergeProps, observable, on, onCleanup, onError, onMount, requestCallback, resetErrorBoundaries, runWithOwner, sharedConfig, splitProps, startTransition, untrack, useContext, useTransition };
    ^^^^^^

    SyntaxError: Unexpected token 'export'

      21 |   sendParent
      22 | } from 'xstate';
    > 23 | import { fromActorRef, useActor } from '../src';
         |                                                 ^
      24 |
      25 | const createSimpleActor = <T extends unknown>(value: T) =>
      26 |   createActor(fromTransition((s) => s, value));

      at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1505:14)
      at Object.require (packages/xstate-solid/test/fromActorRef.test.tsx:23:49)

FAIL packages/xstate-solid/test/useActor.test.tsx
  ● Test suite failed to run

    Jest encountered an unexpected token

    Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax.

    Out of the box Jest supports Babel, which will be used to transform your files into valid JS based on your Babel configuration.

    By default "node_modules" folder is ignored by transformers.

    Here's what you can do:
     • If you are trying to use ECMAScript Modules, see https://jestjs.io/docs/ecmascript-modules for how to enable it.If you are trying to use TypeScript, see https://jestjs.io/docs/getting-started#using-typescript
     • To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
     • If you need a custom transformation specify a "transform" option in your config.
     • If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.

    You'll find more details and examples of these config options in the docs:
    https://jestjs.io/docs/configuration
    For information about custom transformations, see:
    https://jestjs.io/docs/code-transformation

    Details:

    E:\__WorkTable\xstate\node_modules\solid-js\dist\solid.js:1630
    export { $DEVCOMP, $PROXY, $TRACK, DEV, ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, batch, cancelCallback, catchError, children, createComponent, createComputed, createContext, createDeferred, createEffect, createMemo, createReaction, createRenderEffect, createResource, createRoot, createSelector, createSignal, createUniqueId, enableExternalSource, enableHydration, enableScheduling, equalFn, from, getListener, getOwner, indexArray, lazy, mapArray, mergeProps, observable, on, onCleanup, onError, onMount, requestCallback, resetErrorBoundaries, runWithOwner, sharedConfig, splitProps, startTransition, untrack, useContext, useTransition };
    ^^^^^^

    SyntaxError: Unexpected token 'export'

      22 | } from 'xstate';
      23 | import { fromCallback, fromPromise } from 'xstate/actors';
    > 24 | import { useActor } from '../src';
         |                                   ^
      25 |
      26 | function sleep(ms: number) {
      27 |   return new Promise((resolve) => setTimeout(resolve, ms));

      at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1505:14)
      at Object.require (packages/xstate-solid/test/useActor.test.tsx:24:35)


Test Suites: 4 failed, 84 passed, 88 total
Tests:       13 skipped, 1 todo, 1756 passed, 1770 total
Snapshots:   91 passed, 91 total
Time:        11.769 s
Ran all test suites.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Administrator@yr MINGW64 /e/__WorkTable/xstate (main)
$
  • 写回答

5条回答 默认 最新

  • Kwan的解忧杂货铺 Java领域优质创作者 2024-02-28 21:25
    关注

    和平宇宙 晚上好🌙🌙🌙
    本答案参考通义千问

    要在本地部署一个Java Web项目,特别是像xstate这样的基于Node.js的库,你需要遵循以下步骤。由于xstate是一个状态管理库,它本身并不直接支持Java Web应用,但你可以将其与其他技术结合使用,如Express(一个Node.js Web框架)来创建一个RESTful API服务。以下是详细的部署步骤:

    1. 安装Node.js:

      • 如果你还没有安装,首先从Node.js官网下载并安装最新版本。
    2. 克隆项目:

      • 打开命令行终端,cd到你想存放项目的目录,然后运行:
        git clone https://github.com/statelyai/xstate.git
        cd xstate
        
    3. 初始化项目:

      • 进入项目目录后,运行 npm init 以创建一个package.json文件,如果已经存在则跳过。
    4. 安装依赖:

      • 使用 npm installyarn 来安装项目所需的依赖,包括Express和其他可能需要的库。
    5. 创建服务器:

      • src目录下创建一个server.js或类似的文件,然后添加以下内容(假设你使用Express):
        const express = require('express');
        const app = express();
        const port = process.env.PORT || 3000;
        
        // 将xstate定义为一个HTTP API
        app.get('/xstate', (req, res) => {
          // 如果xstate有API接口,直接调用,否则返回一个示例响应
          const xstateApi = require('./your-xstate-api'); // 根据实际情况替换
          res.send(xstateApi());
        });
        
        app.listen(port, () => {
          console.log(`Server listening at http://localhost:${port}`);
        });
        
    6. 启动服务器:

      • 在命令行中运行 node server.jsyarn start
    7. 访问API:

      • 现在你可以在浏览器的地址栏输入 http://localhost:3000/xstate 来查看xstate的API响应。

    注意:xstate本身并没有提供HTTP API,你需要自己实现或者找到一个适合的插件来将它的状态机转换为HTTP请求。如果你想要使用xstate作为状态管理库,可能需要将其与前端JavaScript应用(如React或Vue)结合使用。

    如果你想要在Java Web环境中使用xstate,那么你需要将xstate的状态机定义为JSON或YAML文件,并通过Java处理这些数据。你可能需要一个Java RESTful API来暴露和更新这些状态。这超出了原始问题的范围,但你可以查阅相关资料,例如Spring Boot + JSON-RPC或RESTful API文档。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

问题事件

  • 系统已结题 3月7日
  • 已采纳回答 2月28日
  • 修改了问题 2月28日
  • 修改了问题 2月28日
  • 展开全部

悬赏问题

  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line