#Cannot find package 'react' imported

5 messages · Page 1 of 1 (latest)

patent yacht
#

I'm using Astro and React to build an application, but when I copy the built dist folder to another directory and execute the node entry.mjs in the server folder, it prompts me that the package is missing.

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'react' imported from C:\Users\VeenZhao\Desktop\dist\server\entry.mjs
    at new NodeError (node:internal/errors:399:5)
    at packageResolve (node:internal/modules/esm/resolve:889:9)
    at moduleResolve (node:internal/modules/esm/resolve:938:20)
    at defaultResolve (node:internal/modules/esm/resolve:1153:11)
    at nextResolve (node:internal/modules/esm/loader:163:28)
    at ESMLoader.resolve (node:internal/modules/esm/loader:838:30)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:18)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:77:40)
    at link (node:internal/modules/esm/module_job:76:36) {
  code: 'ERR_MODULE_NOT_FOUND'
}

Node.js v18.15.0
#

this is my config file:

#
import tailwind from "@astrojs/tailwind";
import node from "@astrojs/node";
import react from "@astrojs/react";


// https://astro.build/config
export default defineConfig({
  output: "server",
  integrations: [tailwind({
    config: {
      applyBaseStyles: false
    }
  }), react()],
  adapter: node({
    mode: "standalone"
  })
});```
#

and my package.json:

#
  "name": "ween",
  "type": "module",
  "version": "0.0.1",
  "scripts": {
    "dev": "astro dev --host 127.0.0.1",
    "start": "astro dev",
    "build": "astro build",
    "preview": "astro preview  --host 127.0.0.1",
    "astro": "astro"
  },
  "dependencies": {
    "@astrojs/node": "^5.1.1",
    "@astrojs/react": "^2.1.1",
    "@astrojs/tailwind": "^3.1.1",
    "@types/react": "^18.0.21",
    "@types/react-dom": "^18.0.6",
    "antd": "^5.4.2",
    "astro": "^2.3.0",
    "astro-icon": "^0.8.0",
    "preline": "^1.8.0",
    "react": "^18.0.0",
    "react-dom": "^18.0.0",
    "swr": "^2.1.3",
    "tailwindcss": "^3.3.1"
  },
  "devDependencies": {
    "@iconify/react": "^4.1.0"
  }
}```