Importing wrangler Error
https://website-cvf.pages.dev/
2c9e1f7
6d2375e757659d4dbcefde50d88367ae
Error:
21:01:33.495 error during build:
21:01:33.495 Error [PLUGIN_ERROR]: Cannot find package 'wrangler' imported from /opt/buildhome/repo/node_modules/@sveltejs/adapter-cloudflare/index.js
21:01:33.495 at new NodeError (node:internal/errors:405:5)
21:01:33.495 at packageResolve (node:internal/modules/esm/resolve:887:9)
21:01:33.495 at moduleResolve (node:internal/modules/esm/resolve:936:20)
21:01:33.496 at defaultResolve (node:internal/modules/esm/resolve:1129:11)
21:01:33.496 at nextResolve (node:internal/modules/esm/loader:163:28)
21:01:33.496 at ESMLoader.resolve (node:internal/modules/esm/loader:835:30)
21:01:33.496 at ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:18)
21:01:33.496 at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:77:40)
21:01:33.496 at link (node:internal/modules/esm/module_job:76:36)
21:01:33.546 Failed: Error while executing user command. Exited with error code: 1
21:01:33.557 Failed: build command exited with code: 1
21:01:34.759 Failed: error occurred while running build command
64 Replies
Sounds like
wrangler
isn't installed in the project? e.g. it should show in package.json
and be installed with npm install wrangler --save-dev
as per https://developers.cloudflare.com/workers/wrangler/install-and-update/Oh, okay thank you! how can I install it?
With the command
npm install wrangler --save-dev
in the local project directory, as referenced on the above documentation linkOh okay, sorry I am not a developer my friend gave me the source code as he is sick in the hospital and wanted me to get it all up for him which has been so stressfull
How can I get to the local project directory?
You need to open a terminal in whatever folder on your computer holds the local clone of the project repository. It's quite hard to give generic advice on a beginner topic like this as it depends entirely on how you setup the project originally, so I recommend backtracking through the steps where you initially deployed this project. If it exists on GitHub but you don't have a local copy then you need to clone it, you can research online to learn how to clone and commit changes back to a github repo. For more information about
npm
and nodejs, you can check the documentation link I shared above and the links it references itself.Hey @Erisa
So I did that I added the wrangler
But then I got this error
2024-04-26T20:08:21.93094Z Cloning repository...
2024-04-26T20:08:22.976591Z From https://github.com/loki-lol/website
2024-04-26T20:08:22.977282Z * branch b8f2c09adfe79e514481aca5a82f49a2d7f26749 -> FETCH_HEAD
2024-04-26T20:08:22.977397Z
2024-04-26T20:08:23.028234Z HEAD is now at b8f2c09 Update package.json 2024-04-26T20:08:23.028628Z
2024-04-26T20:08:23.112011Z
2024-04-26T20:08:23.112547Z Using v2 root directory strategy 2024-04-26T20:08:23.138709Z Success: Finished cloning repository files 2024-04-26T20:08:24.848996Z Checking for configuration in a wrangler.toml configuration file (BETA) 2024-04-26T20:08:24.849573Z
2024-04-26T20:08:24.944514Z No wrangler.toml file found. Continuing. 2024-04-26T20:08:25.090224Z Invalid JSON data in package.json file 2024-04-26T20:08:25.091054Z Detected the following tools from environment: [email protected], [email protected] 2024-04-26T20:08:25.091242Z Installing project dependencies: npm clean-install --progress=false 2024-04-26T20:08:26.261318Z npm ERR! code EJSONPARSE 2024-04-26T20:08:26.261518Z npm ERR! path /opt/buildhome/repo/package.json 2024-04-26T20:08:26.263423Z npm ERR! JSON.parse Unexpected token "/" (0x2F) in JSON at position 1298 while parsing near "...gler-js": "^0.1.11" // Added wrangler-js..." 2024-04-26T20:08:26.263797Z npm ERR! JSON.parse Failed to parse JSON data. 2024-04-26T20:08:26.264045Z npm ERR! JSON.parse Note: package.json must be actual JSON, not just JavaScript. 2024-04-26T20:08:26.265533Z
2024-04-26T20:08:26.265666Z npm ERR! A complete log of this run can be found in: /opt/buildhome/.npm/_logs/2024-04-26T20_08_25_789Z-debug-0.log 2024-04-26T20:08:26.274731Z Error: Exit with error code: 1 2024-04-26T20:08:26.27496Z at ChildProcess.<anonymous> (/snapshot/dist/run-build.js) 2024-04-26T20:08:26.275135Z at Object.onceWrapper (node:events:652:26) 2024-04-26T20:08:26.275245Z at ChildProcess.emit (node:events:537:28) 2024-04-26T20:08:26.275311Z at ChildProcess._handle.onexit (node:internal/child_process:291:12) 2024-04-26T20:08:26.286324Z Failed: build command exited with code: 1 2024-04-26T20:08:27.3638Z Failed: error occurred while running build command
2024-04-26T20:08:23.028234Z HEAD is now at b8f2c09 Update package.json 2024-04-26T20:08:23.028628Z
2024-04-26T20:08:23.112011Z
2024-04-26T20:08:23.112547Z Using v2 root directory strategy 2024-04-26T20:08:23.138709Z Success: Finished cloning repository files 2024-04-26T20:08:24.848996Z Checking for configuration in a wrangler.toml configuration file (BETA) 2024-04-26T20:08:24.849573Z
2024-04-26T20:08:24.944514Z No wrangler.toml file found. Continuing. 2024-04-26T20:08:25.090224Z Invalid JSON data in package.json file 2024-04-26T20:08:25.091054Z Detected the following tools from environment: [email protected], [email protected] 2024-04-26T20:08:25.091242Z Installing project dependencies: npm clean-install --progress=false 2024-04-26T20:08:26.261318Z npm ERR! code EJSONPARSE 2024-04-26T20:08:26.261518Z npm ERR! path /opt/buildhome/repo/package.json 2024-04-26T20:08:26.263423Z npm ERR! JSON.parse Unexpected token "/" (0x2F) in JSON at position 1298 while parsing near "...gler-js": "^0.1.11" // Added wrangler-js..." 2024-04-26T20:08:26.263797Z npm ERR! JSON.parse Failed to parse JSON data. 2024-04-26T20:08:26.264045Z npm ERR! JSON.parse Note: package.json must be actual JSON, not just JavaScript. 2024-04-26T20:08:26.265533Z
2024-04-26T20:08:26.265666Z npm ERR! A complete log of this run can be found in: /opt/buildhome/.npm/_logs/2024-04-26T20_08_25_789Z-debug-0.log 2024-04-26T20:08:26.274731Z Error: Exit with error code: 1 2024-04-26T20:08:26.27496Z at ChildProcess.<anonymous> (/snapshot/dist/run-build.js) 2024-04-26T20:08:26.275135Z at Object.onceWrapper (node:events:652:26) 2024-04-26T20:08:26.275245Z at ChildProcess.emit (node:events:537:28) 2024-04-26T20:08:26.275311Z at ChildProcess._handle.onexit (node:internal/child_process:291:12) 2024-04-26T20:08:26.286324Z Failed: build command exited with code: 1 2024-04-26T20:08:27.3638Z Failed: error occurred while running build command
Your
package.json
contains comments (bits starting //
) which aren't a valid thing in json, also not sure why you have wrangler-js
and not wrangler
?Oh?
This was it before
{
"name": "betrayal.lol",
"version": "0.0.1",
"private": true,
"scripts": {
"dev": "vite dev",
"build": "vite build",
"preview": "vite preview",
"test": "playwright test",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
"test:unit": "vitest",
"lint": "prettier --plugin-search-dir . --check . && eslint .",
"format": "prettier --plugin-search-dir . --write ."
},
"devDependencies": {
"@playwright/test": "^1.28.1",
"@poppanator/sveltekit-svg": "^2.1.2",
"@supabase/auth-helpers-sveltekit": "^0.8.6",
"@supabase/supabase-js": "^2.1.3",
"@sveltejs/adapter-auto": "next",
"@sveltejs/kit": "^1.30.4",
"@typescript-eslint/eslint-plugin": "^5.45.0",
"@typescript-eslint/parser": "^5.45.0",
"autoprefixer": "^10.4.7",
"axios": "^1.3.4",
"eslint": "^8.28.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-svelte3": "^4.0.0",
"prettier": "^2.8.0",
"prettier-plugin-svelte": "^2.8.1",
"sass": "^1.57.1",
"svelte": "^3.54.0",
"svelte-check": "^2.9.2",
"svelte-turnstile": "^0.3.1",
"tslib": "^2.4.1",
"typescript": "^4.9.3",
"vite": "^4.0.0",
"vitest": "^0.25.3"
},
"dependencies": {
"@fortawesome/free-brands-svg-icons": "^6.2.1",
"@fortawesome/free-solid-svg-icons": "^6.2.1",
"@sveltejs/adapter-cloudflare": "^4.2.0",
"svelte-fa": "^3.0.3",
"sveltestrap": "^5.10.0"
},
"type": "module"
}
I asked Chat GPT: intergrate the code from https://unpkg.com/browse/[email protected]/package.json to my original package.json (then pasted what I just sent you above^)
UNPKG - wrangler-js
The CDN for wrangler-js
And it gave me this : {
"name": "betrayal.lol",
"version": "0.0.1",
"private": true,
"scripts": {
"dev": "vite dev",
"build": "vite build",
"preview": "vite preview",
"test": "playwright test",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
"test:unit": "vitest",
"lint": "prettier --plugin-search-dir . --check . && eslint .",
"format": "prettier --plugin-search-dir . --write ."
},
"devDependencies": {
"@playwright/test": "^1.28.1",
"@poppanator/sveltekit-svg": "^2.1.2",
"@supabase/auth-helpers-sveltekit": "^0.8.6",
"@supabase/supabase-js": "^2.1.3",
"@sveltejs/adapter-auto": "next",
"@sveltejs/kit": "^1.30.4",
"@typescript-eslint/eslint-plugin": "^5.45.0",
"@typescript-eslint/parser": "^5.45.0",
"autoprefixer": "^10.4.7",
"axios": "^1.3.4",
"eslint": "^8.28.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-svelte3": "^4.0.0",
"prettier": "^2.8.0",
"prettier-plugin-svelte": "^2.8.1",
"sass": "^1.57.1",
"svelte": "^3.54.0",
"svelte-check": "^2.9.2",
"svelte-turnstile": "^0.3.1",
"tslib": "^2.4.1",
"typescript": "^4.9.3",
"vite": "^4.0.0",
"vitest": "^0.25.3",
"wrangler-js": "^0.1.11" // Added wrangler-js to devDependencies
},
"dependencies": {
"@fortawesome/free-brands-svg-icons": "^6.2.1",
"@fortawesome/free-solid-svg-icons": "^6.2.1",
"@sveltejs/adapter-cloudflare": "^4.2.0",
"svelte-fa": "^3.0.3",
"sveltestrap": "^5.10.0"
},
"type": "module"
}
What should I do @Erisa?
You shouldn't use chatgpt for this
Oh I'm sorry.
wrangler-js is not the right package, that is not the right process and it messed up your package.json
the correct process is explained on https://developers.cloudflare.com/workers/wrangler/install-and-update/
Could I hire you to do it? Ill pay you $20
I'm really confused
No, I won't be doing that sorry
Oh
Do you know anyone who could do it for pay?
As this is really stressful
And I keep messing it up
Unless there is an easy fix that I am missing.
You need to change your package.json to the following:
Don't add anything else, just that package.json.
In the future just keep in mind that ChatGPT is not very good at code (especially GPT3.5) and will often give you incorrect, misleading, or outright false information.
Do I just copy that and replace it on github?
Ah
Replace it completely, yes.
Okay, thank you.
OKay, let me do that.
It's been stuck on this for 4 minutes is that bad?
Nope, just got to be patient
Ah, okay !
If it's stuck a while longer you can stop and restart the build
Just making sure
Alright, ill wait for about 3 more miuntes.
Stuck there with this;
K, try restarting the build.
Okay.
Same error
It sounds like your build command is failing somehow. Can you show the logs above those lines?
OK, your package-lock.json file and your package.json file are out of sync. Do you have the project locally on your computer?
If not you'll need to get it on your computer, and install Node.js.
Umm, what do you mean?
I do not have that installed
The project is on Github, but in order to fix this you'll need the project on your computer.
Oh, okay can you send me the link please
You need to install Node.js: https://nodejs.org/en
Node.js — Run JavaScript Everywhere
Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine.
And git: https://git-scm.com/
If this is too tricky you might just want to wait for your friend, we can only help so much and a decent amount of knowledge is required to get this kind of thing up and running.
Ill try my best, my friend will be out for a while.
And I am gratful for everyone's help
Okay, let me install this one molment
@Isaac McFadyen | YYZ01. what happened here?
It's very tricky to know - what did you try to do?
I didnt do anything
Just let it run
Should I restart?
What did you run though?
Windows PowerShell?
You just opened it?
Yes
It got most of it, it just stopped there.
Why are you installing chocolaty?
You shouldn't need to do that.
I installed what you told me too?
?
Yeah, and when you hit download what kind of file do you get?
And you double-clicked on that and it opened PowerShell?
Yea
Interesting - it might be that your PowerShell is too old a version or something. I'm sorry but I can't really help at this point, I don't know much about Windows and it's also very tricky to debug all this stuff remotely.
:SAD:
It seems like nobody has been able to help me not my friends or ppl I try and ask :/
All I want it to get this site up for him
Could you try and fix it, if I hired you for commistion?
Or maybe try and help me a little more please :/
I'm sorry but I really can't help further, and we don't work for commission - we're community volunteers.
Oh :/
What what should I do?
You could try finding a community dedicated to helping out web developers, there's probably some Discord servers that help with that.
Oh I see.
Well may I ask one last thing.
Sure, feel free to ask, but I might not know the answer.
How may I resolove this?
You need to update the nameservers of the domain, which means you'll need access to wherever the domain is registered (whoever you pay for the domain).
I pay namecheap
Then you'll need to log into Namecheap and update the nameservers there. You can follow this guide, just follow all the steps and then select Namecheap under the Step 3 dropdown: https://developers.cloudflare.com/dns/zone-setups/full-setup/setup/