question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Main package should be compiled for node env

See original GitHub issue

I had an issue with the axios library when I was using axios in the main package, the code was resolving to the XHR adapter. It was happening due to this field in package.json of axios:

  "browser": {
    "./lib/adapters/http.js": "./lib/adapters/xhr.js"
  },

It means that for browser env ./lib/adapters/http.js file should be replaced with ./lib/adapters/xhr.js, but main package is running under node environment, and it was causing the error. Here is the more detailed issue https://github.com/vitejs/vite/issues/6382 .

So, I fixed it with ssr: true in the build section of config.vite.js. What do you think about this? I can provide PR if you want 🙂

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
cawa-93commented, Jan 11, 2022

It seems build in ssr: true works fine for main and preload. But I can’t dare use it because SSR support is still experimental.

1reaction
cawa-93commented, Jan 6, 2022

Btw, I still think that the main package should use ssr: true,

You may be right. But I need more tests and research for that change

Read more comments on GitHub >

github_iconTop Results From Across the Web

Environment variables in Node.js. The Right way!
This is my first blog post. Hope y'all like it . Environment variables are very fundamental part of developing with Node.js or any...
Read more >
node.js - How to put .env and other filed in dist folder while ...
To resolve this issue, I need to copy my all the configuration/static files (here, .env file) into ./dist folder at the time of...
Read more >
Best Practices for Node.js Development - Heroku Dev Center
A list of tips and techniques to keep you and your Node apps happy.
Read more >
Modules: Packages | Node.js v19.3.0 Documentation
Introduction#. A package is a folder tree described by a package.json file. The package consists of the folder containing the package.json file and...
Read more >
Best practices for creating a modern npm package - Snyk
In this tutorial, we're going to walk step by step through creating an npm package using modern best practices (as of 2022).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found