🐛 BUG: `npx wrangler publish` cannot resolve root npm packages
See original GitHub issueWhat version of Wrangler
are you using?
2.0.1
What operating system are you using?
Mac
Describe the Bug
I have an existing project was published using Wrangler 1. The wrangler.toml
file looks like below.
name = "my-project-name"
main = "./"
account_id = "abc12345..."
route = "foo.bar.com/*"
workers_dev = true
[env]
compatibility_date = "2022-04-01"
[build]
command = "npm install && npm run build"
After installed wrangler2 package using npm install wrangler --save-dev
and run npx wrangler publish
I got the error below.
...
webpack 5.38.1 compiled successfully in 764 ms
✘ [ERROR] Could not resolve "" after running custom build: npm install && npm run build
Same project can be published without problem using wrangler1 though wrangler publish
command.
Publish also works if I run npm install && npm run build
directly.
Issue Analytics
- State:
- Created a year ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Wrangler npm global install fails when run as 'root' #2063
The wrangler npm global install fails when run as 'root'. This includes the use case of building a docker image.
Read more >Error: cannot find module [Node npm Error Solved]
To fix the error, you need to install the package that is absent in your project directory – npm install package-name or yarn...
Read more >node.js - Node MODULE_NOT_FOUND
The MODULE_NOT_FOUND error seems to happen when changing between node versions and some files are possibly still being cached.
Read more >wrangler
Command-line interface for all things Cloudflare Workers. Latest version: 2.6.2, last published: 13 days ago. Start using wrangler in your ...
Read more >10 things I love about Wrangler v2.0
Let's fix that. We've simplified this by now publishing to the wrangler package, so you can run npm install wrangler and it works...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for reporting this issue.
The problem appears to be that Wrangler 2 expects the
main
property to be the path to the output from the custom build.Let’s assume that your webpack build is outputting to
dist/index.js
, then in wrangler.toml your would needOne last thing. Can you tell me if you added the
main
field as part of your upgrade to Wrangler 2? Or was it already there from Wrangler 1? I believe that Wrangler 1 would not use this field, and that our deprecation warning ought to have told you to usedist
. For example: