Instead of “import” in js file, i used script tag in HTML… for three js, it is working file… but when i add orbit controls again it is showing the same issue
this part i do not understand. why do you suddenly import from /js? you have to import from the same cdn, skypack. you normally can’t use npm without a bundler, sky auto bundles it for you.
i am not using any NPM Server, i am using STATIC HTML, with script tag to import this js file
i think you’re mixing up something. npm is for creating static builds. the files you pull are bundled into a static distribution that is then self contained and can just be uploaded anywhere. you are currently relying on a shaky remote server with downtimes, you literally pull files from an npm server.
hi drcmda,
i am having a shared hosting server, where there is no node support, so i seperate it from bundler and put it in js file download… but still i have issues… when i work in local, everything works fine… but when i upload it online it is not… for ex: https://arackofideas.in/3dModal/ see this link… for me same files working fine in local but… when i put in sever… it is not working it is showing all the error is the world one by one… can you help with this… as i could not able to understand this node…
hosting has nothing to do with npm. npm is only for local dev, as well as the bundler. you build with npm, you don’t publish it.
the bundler inlines your dependency into one self contained folder (dist) which you then upload to the hoster. from that point on your site does not depend on anything but its own static files. your project can then also run offline because there are no further remote connections being made.
if you use skypack though, it indeed goes to npm and pulls files, auto bundles them. it is shaky because cdn’s have down-times, it would not work offline.
as i said, you most likely don’t want to depend on skypack in production. and this stuff is a hundred times more complicated and bugged than just picking a bundler.
try this:
npm init vite
follow the instructions. then npm install three. and now just build your project. run npm run dev to debug it live in the browser. any change you make in your editor is reflected there.
import * as THREE from 'three'
import { OrbitControls } from 'three/examples/jsm/OrbitControls'
...
and when you’re done hit npm run build which creates a self contained dist folder for you. you upload that to your hoster and it’s done.