我正在使用three.js parcel bundler进行一个项目。
在我当地的系统里一切都很正常。但是,当我试图将它部署到Netlify上时,会出现以下错误:
Uncaught ReferenceError: i is not defined at app.js:45:16app.js中45的代码是:
/*41*/ const particlesGeo = new THREE.BufferGeometry();
/*42*/ const particlesMat = new THREE.PointsMaterial({
/*43*/ size: 0.01,
/*44*/ map: loader.load(sparkleTexture),
/*45*/ transparent: true,
/*46*/ });我尝试了不同的平台来进行部署,而激增是非常完美的。netlify有什么问题吗?
Netlify生成设置:

package.json:
{
"name": "particle-system",
"version": "1.0.0",
"description": "",
"source": "src/index.html", // Added due to parcel error in netlify production
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"gsap": "^3.11.3",
"parcel": "^2.7.0",
"three": "^0.145.0"
}
}链接:
发布于 2022-10-23 12:45:15
您的app.js文件中有以下一行:
for (i = 0; i < particlesCount * 3; i++) {运行时错误是由于未定义i而发生的。将代码更改为:
for (let i = 0; i < particlesCount * 3; i++) {https://stackoverflow.com/questions/74169746
复制相似问题