hongfaqiu / MVTImageryProvider

Mapbox vector tiles(pbf) visulization on cesium
https://mvt-provider.opendde.com/
MIT License
63 stars 19 forks source link

Failed to load module script error when deploying to server #24

Open winnieChen00 opened 4 months ago

winnieChen00 commented 4 months ago

When I deploy the project to my server, I receive the following error in the browser console: Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "". Strict MIME type checking is enforced for module scripts per HTML spec.(index.ts:1)

Also, I can confirm that the application runs correctly on my local development environment by following these steps: pnpm install cd example pnpm dev

The application works correctly without any errors.

Do you have any suggestions on how to resolve this issue or further steps I can take to debug it?

Thank you for your help!

hongfaqiu commented 4 months ago

@winnieChen00 Please check your build configuration and deployment environment configuration.

If you want to test the packaging effect on your local machine, you can use the following commands:

pnpm build
npx vite preview

This will start an Express server to host your packaged artifacts.

winnieChen00 commented 3 months ago

Thank you for the suggestion.

When I try to run pnpm build, I encounter the following error: 'build' is not recognized as an internal or external command, operable program or batch file.  ERR_PNPM_RECURSIVE_EXEC_FIRST_FAIL  Command "build" not found

It seems like the build script is not defined in the package.json file. Could you please clarify how to configure the build script or what the expected build command is?

Thank you for your assistance.

hongfaqiu commented 3 months ago

@winnieChen00 My question. Please ensure that the execution path of your terminal command is./packages/ MVTImageryProvider/

winnieChen00 commented 3 months ago

After running pnpm build, I try to run npx vite preview,and I I encounter the following error: error when starting preview server: Error: The directory "dist" does not exist. Did you build your project?

I verified that the build script is defined in package.json. I made sure that I am running the command in the correct directory. I checked the console output, and there were no obvious errors during the build process. However, despite these checks, the dist directory is still not created. I would greatly appreciate it if you could provide some guidance on how to resolve this issue or if there is something specific I should be checking in the project configuration.

Thank you for your assistance.

hongfaqiu commented 3 months ago

@winnieChen00 The npx vite preview command also needs to be executed in the ./example/ directory The overall steps are as follows:

  1. Execute pnpm i in the root directory to install dependencies. After successful installation, the pnpm build:lib command will be automatically executed to package the packages in the packages directory.
  2. Enter the example directory and execute the pnpm dev command to start the development server.
  3. To package the example project, please execute the pnpm build command in the example directory.
  4. If you want to preview the packaged effect, please execute the npx vite preview command in the example directory.