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.

Vite error in make-crypter.js - Vite seems to think "crypto" is a local module

See original GitHub issue

Just updated svelte-kit-cookie-session from 1.2.4 to 1.3.0, and now I’m getting the following Vite error whenever I run pnpm run dev:

1:10:31 PM [vite] new dependencies found: svelte-kit-cookie-session, updating...
 > node_modules/svelte-kit-cookie-session/dist/utils/crypto/make-crypter.js:9:75: error: Could not read from file: (REPOROOT)/crypto
    9 │ import { pbkdf2Sync, createDecipheriv, createCipheriv, randomBytes, } from "crypto";
      ╵                                                                            ~~~~~~~~

(I replaced my repo root with the text (REPOROOT) above since I’m running this from a directory nested about five deep in my folder hierarchy, and without that replacement the error message was even more annoyingly long than it already is.)

Running with npm instead of pnpm I get the same error. However, if I run pnpm run build followed by pnpm run preview then everything works.

I know I need to somehow tell Vite that svelte-kit-cookie-session is only Node-based and should therefore be allowed to import Node packages like crypto, but I’m not yet familiar enough with Svelte-Kit to know how to do that off the top of my head. Which leads me to report it here, because you might want to add something to the svelte-kit-cookie-session README about how to work around this Vite behavior. (And I’ll update this issue if I figure it out.)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
pixelmundcommented, Jul 23, 2021

I have updated the README and going to close this issue now. I’m on UTC+1

0reactions
rmunncommented, Jul 23, 2021

Perfect, i’m adding it to the readme. Thanks for verifying 😃

Great; I’ll close the issue once the README is updated, or you can close it if I don’t get to it. (I’m in a far eastern timezone, UTC+lots, so I go to sleep while most of America is just waking up).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Case Study: Should We Embrace Crypto?
The CFO of an online education platform considers whether to adopt Bitcoin for payments and investments.
Read more >
Node.js crypto module: A tutorial - LogRocket Blog
We'll build a sample app to demonstrate how to encrypt and decrypt usernames and passwords in Node.js using crypto. Here's what we'll cover:....
Read more >
Coinbase S-1 - SEC.gov
Each share of Class A common stock is entitled to one vote. ... •Companies focused on the crypto asset market, some of whom...
Read more >
Crypto-Assets: Implications for Consumers, Investors, and ...
A DAO governance token allows holders to vote on decisions pertaining to the underlying decentralized finance protocol. See.
Read more >
Node.js Crypto Module - W3Schools
Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant ......
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