neo4j-labs / llm-graph-builder

Neo4j graph construction from unstructured data using LLMs
https://neo4j.com/labs/genai-ecosystem/llm-graph-builder/
Apache License 2.0
2.57k stars 412 forks source link

Error: [vite]: Rollup failed to resolve import "@segment/analytics-next" #669

Closed lissettecarlr closed 3 months ago

lissettecarlr commented 3 months ago

When I used the main branch, I encountered similar errors. After checking the issues, I learned that I should use the dev branch, but errors still occurred. Below are the commands I executed

git clone -b DEV https://github.com/neo4j-labs/llm-graph-builder.git
cd llm-graph-builder
cp example.env .env
sudo docker-compose up --build

The error log is as follows:

 => ERROR [frontend build 7/7] RUN BACKEND_API_URL=http://localhost:8000     RE  18.8s
------
 > [frontend build 7/7] RUN BACKEND_API_URL=http://localhost:8000     REACT_APP_SOURCES=local,youtube,wiki,s3,web     LLM_MODELS=diffbot,openai-gpt-3.5,openai-gpt-4o     GOOGLE_CLIENT_ID=     BLOOM_URL=https://workspace-preview.neo4j.io/workspace/explore?connectURL={CONNECT_URL}&search=Show+me+a+graph&featureGenAISuggestions=true&featureGenAISuggestionsInternal=true&search=Show+me+a+graph&featureGenAISuggestions=true&featureGenAISuggestionsInternal=true}     TIME_PER_CHUNK=4     CHUNK_SIZE=5242880     ENV=DEV     LARGE_FILE_SIZE=5242880     CHAT_MODES=     yarn run build:
0.537 yarn run v1.22.22
0.575 $ tsc && vite build
8.181 vite v4.5.3 building for production...
8.225 transforming...
10.19
10.19 warn - The safelist pattern `/^(hover:)?n-text-(palette|dark|light|primary|danger|warning|success|blueberry|mint|neutral)-/` doesn't match any Tailwind CSS classes.
10.19 warn - Fix this pattern or remove it from your `safelist` configuration.
10.19 warn - https://tailwindcss.com/docs/content-configuration#safelisting-classes
10.19
10.19 warn - The safelist pattern `/^(hover:)?n-bg-(palette|dark|light|primary|danger|warning|success|blueberry|mint|neutral)-/` doesn't match any Tailwind CSS classes.
10.19 warn - Fix this pattern or remove it from your `safelist` configuration.
10.19 warn - https://tailwindcss.com/docs/content-configuration#safelisting-classes
10.19
10.19 warn - The safelist pattern `/^(active:)?n-bg-(palette|dark|light|primary|danger|warning|success|blueberry|mint|neutral)-/` doesn't match any Tailwind CSS classes.
10.19 warn - Fix this pattern or remove it from your `safelist` configuration.
10.19 warn - https://tailwindcss.com/docs/content-configuration#safelisting-classes
10.19
10.19 warn - The safelist pattern `/^(hover:)?n-border-(palette|dark|light|primary|danger|warning|success|blueberry|mint|neutral)-/` doesn't match any Tailwind CSS classes.
10.19 warn - Fix this pattern or remove it from your `safelist` configuration.
10.19 warn - https://tailwindcss.com/docs/content-configuration#safelisting-classes
18.61 ✓ 2696 modules transformed.
18.61 ✓ built in 10.43s
18.61 [vite]: Rollup failed to resolve import "@segment/analytics-next" from "/app/node_modules/@neo4j-nvl/base/dist/base.mjs".
18.61 This is most likely unintended because it can break your application at runtime.
18.61 If you do want to externalize this module explicitly add it to
18.61 `build.rollupOptions.external`
18.62 error during build:
18.62 Error: [vite]: Rollup failed to resolve import "@segment/analytics-next" from "/app/node_modules/@neo4j-nvl/base/dist/base.mjs".
18.62 This is most likely unintended because it can break your application at runtime.
18.62 If you do want to externalize this module explicitly add it to
18.62 `build.rollupOptions.external`
18.62     at viteWarn (file:///app/node_modules/vite/dist/node/chunks/dep-41cf5ffd.js:48216:27)
18.62     at onwarn (file:///app/node_modules/@vitejs/plugin-react/dist/index.mjs:266:9)
18.62     at onRollupWarning (file:///app/node_modules/vite/dist/node/chunks/dep-41cf5ffd.js:48245:9)
18.62     at onwarn (file:///app/node_modules/vite/dist/node/chunks/dep-41cf5ffd.js:47976:13)
18.62     at file:///app/node_modules/rollup/dist/es/shared/node-entry.js:24276:13
18.62     at Object.logger [as onLog] (file:///app/node_modules/rollup/dist/es/shared/node-entry.js:25950:9)
18.62     at ModuleLoader.handleInvalidResolvedId (file:///app/node_modules/rollup/dist/es/shared/node-entry.js:24862:26)
18.62     at file:///app/node_modules/rollup/dist/es/shared/node-entry.js:24822:26
18.71 info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
18.71 error Command failed with exit code 1

failed to solve: process "/bin/sh -c BACKEND_API_URL=$BACKEND_API_URL     REACT_APP_SOURCES=$REACT_APP_SOURCES     LLM_MODELS=$LLM_MODELS     GOOGLE_CLIENT_ID=$GOOGLE_CLIENT_ID     BLOOM_URL=$BLOOM_URL     TIME_PER_CHUNK=$TIME_PER_CHUNK     CHUNK_SIZE=$CHUNK_SIZE     ENV=$ENV     LARGE_FILE_SIZE=${LARGE_FILE_SIZE}     CHAT_MODES=$CHAT_MODES     yarn run build" did not complete successfully: exit code: 1
kartikpersistent commented 3 months ago

Hi @lissettecarlr thanks for pointing out we will try to replicate.

kartikpersistent commented 3 months ago

we informed nvl team they are looking at this

elheremes commented 3 months ago

Got the same error, DEV branch was working fine until yesterday for me, when I tried to build again this error appeared.

elheremes commented 3 months ago

Achieve a temporary fix by making these changes:

frontend/package.json

    "@neo4j-nvl/base": "0.3.1", # "^0.3.1" changed to "0.3.1" 
    "@neo4j-nvl/react": "0.3.1", # "^0.3.1" changed to "0.3.1"  

frontend/Dockerfile

WORKDIR /app
COPY package.json yarn.lock ./
# RUN yarn add @neo4j-nvl/base @neo4j-nvl/react # Remove or comment this line
RUN yarn cache clean # Don't know if this is needed, but added anyway
RUN yarn install
COPY . ./
kartikpersistent commented 3 months ago

Hi @elheremes Did you get any type errors after you tried docker-compose

elheremes commented 3 months ago

Hi @elheremes Did you get any type errors after you tried docker-compose

No errors after these changes.

image

kartikpersistent commented 3 months ago

@elheremes which node version you are using?

elheremes commented 3 months ago

@elheremes which node version you are using?

I'm pretty certain its node:20, didn't change any of that. Going to post the entire content of the Dockerfile and package.json I'm using:

package.json

{
  "name": "neo4j-needle-starterkit",
  "private": true,
  "version": "1.0.0",
  "type": "module",
  "scripts": {
    "dev": "vite --host 0.0.0.0",
    "build": "tsc && vite build",
    "format": "prettier --write \"**/*.{ts,tsx}\"",
    "lint": "eslint --ext .ts --ext .tsx . --report-unused-disable-directives --max-warnings 0",
    "preview": "vite preview"
  },
  "dependencies": {
    "@emotion/styled": "^11.11.0",
    "@mui/material": "^5.15.10",
    "@mui/styled-engine": "^5.15.9",
    "@neo4j-devtools/word-color": "^0.0.8",
    "@neo4j-ndl/base": "^2.11.6",
    "@neo4j-ndl/react": "^2.15.10",
    "@neo4j-nvl/base": "0.3.1",
    "@neo4j-nvl/react": "0.3.1",
    "@react-oauth/google": "^0.12.1",
    "@types/uuid": "^9.0.7",
    "axios": "^1.6.5",
    "clsx": "^2.1.1",
    "eslint-plugin-react": "^7.33.2",
    "neo4j-driver": "^5.14.0",
    "re-resizable": "^6.9.16",
    "react": "^18.3.1",
    "react-dom": "^18.3.1",
    "react-icons": "^5.2.1",
    "react-markdown": "^9.0.1",
    "react-router": "^6.23.1",
    "react-router-dom": "^6.23.1",
    "remark-gfm": "^4.0.0",
    "tailwind-merge": "^2.3.0",
    "uuid": "^9.0.1"
  },
  "devDependencies": {
    "@types/node": "^20.11.10",
    "@types/react": "^18.2.15",
    "@types/react-dom": "^18.2.7",
    "@typescript-eslint/eslint-plugin": "^6.0.0",
    "@typescript-eslint/parser": "^6.0.0",
    "@vitejs/plugin-react": "^4.0.3",
    "autoprefixer": "^10.4.17",
    "eslint": "^8.45.0",
    "eslint-config-prettier": "^8.5.0",
    "eslint-plugin-react-hooks": "^4.6.0",
    "eslint-plugin-react-refresh": "^0.4.3",
    "postcss": "^8.4.33",
    "prettier": "^2.7.1",
    "react-dropzone": "^14.2.3",
    "tailwindcss": "^3.4.1",
    "typescript": "^5.0.2",
    "vite": "^4.5.3"
  }
}

Dockerfile

# Step 1: Build the React application
FROM node:20 AS build

ARG BACKEND_API_URL="http://localhost:8000"
ARG REACT_APP_SOURCES=""
ARG LLM_MODELS=""
ARG GOOGLE_CLIENT_ID=""
ARG BLOOM_URL="https://workspace-preview.neo4j.io/workspace/explore?connectURL={CONNECT_URL}&search=Show+me+a+graph&featureGenAISuggestions=true&featureGenAISuggestionsInternal=true"
ARG TIME_PER_CHUNK=4
ARG TIME_PER_PAGE=50
ARG LARGE_FILE_SIZE=5242880
ARG CHUNK_SIZE=5242880
ARG CHAT_MODES=""
ARG ENV="DEV"

WORKDIR /app
COPY package.json yarn.lock ./
# RUN yarn add @neo4j-nvl/base @neo4j-nvl/react
RUN yarn cache clean
RUN yarn install
COPY . ./
RUN BACKEND_API_URL=$BACKEND_API_URL \
    REACT_APP_SOURCES=$REACT_APP_SOURCES \
    LLM_MODELS=$LLM_MODELS \
    GOOGLE_CLIENT_ID=$GOOGLE_CLIENT_ID \
    BLOOM_URL=$BLOOM_URL \
    TIME_PER_CHUNK=$TIME_PER_CHUNK \
    CHUNK_SIZE=$CHUNK_SIZE \
    ENV=$ENV \
    LARGE_FILE_SIZE=${LARGE_FILE_SIZE} \
    CHAT_MODES=$CHAT_MODES \
    yarn run build

# Step 2: Serve the application using Nginx
FROM nginx:alpine
COPY --from=build /app/dist /usr/share/nginx/html
COPY nginx/nginx.conf /etc/nginx/conf.d/default.conf

EXPOSE 8080
CMD ["nginx", "-g", "daemon off;"]

Sorry if I'm not responding clearly, I don't have much experience using docker environments.

lissettecarlr commented 3 months ago

Thanks for the help,I tried modifying frontend/package.json and frontend/Dockerfile, but the error message during the build remained unchanged.

vim frontend/package.json

"@neo4j-nvl/base": "^0.3.2"   ->  "@neo4j-nvl/base": "^0.3.1",
"@neo4j-nvl/react": "^0.3.2", ->  "@neo4j-nvl/base": "^0.3.1",

and

vim frontend/Dockerfile

# Step 1: Build the React application
FROM node:20 AS build

ARG BACKEND_API_URL="http://localhost:8000"
ARG REACT_APP_SOURCES=""
ARG LLM_MODELS=""
ARG GOOGLE_CLIENT_ID=""
ARG BLOOM_URL="https://workspace-preview.neo4j.io/workspace/explore?connectURL={CONNECT_URL}&search=Show+me+a+graph&featureGenAISuggestions=true&featureGenAISuggestionsInternal=true"
ARG TIME_PER_CHUNK=4
ARG TIME_PER_PAGE=50
ARG LARGE_FILE_SIZE=5242880
ARG CHUNK_SIZE=5242880
ARG CHAT_MODES=""
ARG ENV="DEV"

WORKDIR /app
COPY package.json yarn.lock ./
RUN yarn cache clean :q
RUN yarn install
COPY . ./

RUN BACKEND_API_URL=$BACKEND_API_URL \
    REACT_APP_SOURCES=$REACT_APP_SOURCES \
    LLM_MODELS=$LLM_MODELS \
    GOOGLE_CLIENT_ID=$GOOGLE_CLIENT_ID \
    BLOOM_URL=$BLOOM_URL \
    TIME_PER_CHUNK=$TIME_PER_CHUNK \
    CHUNK_SIZE=$CHUNK_SIZE \
    ENV=$ENV \
    LARGE_FILE_SIZE=${LARGE_FILE_SIZE} \
    CHAT_MODES=$CHAT_MODES \
    yarn run build

# Step 2: Serve the application using Nginx
FROM nginx:alpine
COPY --from=build /app/dist /usr/share/nginx/html
COPY nginx/nginx.conf /etc/nginx/conf.d/default.conf

EXPOSE 8080
CMD ["nginx", "-g", "daemon off;"]

I only modified these two places above, then compiled, and the error log was exactly the same as before.

kartikpersistent commented 3 months ago

Hi @lissettecarlr and @elheremes
As temporary fix add nvl packages in resolutions in package.json and remove yarn add @neo4j-nvl/base @neo4j-nvl/react from frontend docker For the references check Branch

EX:

  "resolutions": {
    "@neo4j-nvl/base": "0.3.1",
    "@neo4j-nvl/react":"0.3.1"
  }
lissettecarlr commented 3 months ago

I used the new branch: origin/Concurrent-Processing-of-files, and successfully deployed it with Docker. Thanks~

edferr commented 3 months ago

I used the new branch: origin/Concurrent-Processing-of-files, and successfully deployed it with Docker. Thanks~

can confirm. default branch docker will not build. new branch builds without error

kartikpersistent commented 3 months ago

Yes DEV version is updated with these changes

maxlawdify commented 3 months ago

Hi, I updated my package.json with the one in DEV branch but keep having same problem, I did clean install remove cache etc, is there anything else that require changes?

kartikpersistent commented 3 months ago

Hey @maxlawdify NVL team released the 0.3.3 version they resolved all the issues. refer to the DEV branch package.json and vite.config.ts for successfully building the project.