N
Nuxt8h ago
Frox

ohash error eferenceError: Cannot access 'defaults' before initialization

Nitro fails to starts: I've tracked the problem to ohash function:
function objectHash(object, options) {
if (options) {
options = { ...defaults, ...options };
} else {
options = defaults;
}
const hasher = createHasher(options);
hasher.dispatch(object);
return hasher.toString();
}
function objectHash(object, options) {
if (options) {
options = { ...defaults, ...options };
} else {
options = defaults;
}
const hasher = createHasher(options);
hasher.dispatch(object);
return hasher.toString();
}
How to solve this?
6 Replies
kapa.ai
kapa.ai8h ago
Hi @Frox. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Based on the information provided in the knowledge sources, I don't have enough specific details to directly address the ohash error you're encountering. However, I can provide some context and a potential solution based on recent updates to the ohash package used by Nuxt. The error you're seeing suggests that there's an issue with accessing the defaults variable before it's initialized in the objectHash function. This could be related to a recent update in the ohash package. According to the ohash update pull request, Nuxt recently updated its dependency on ohash from version ^1.1.3 to ^1.1.4. This update included some fixes and improvements, particularly to the murmurHash implementation. To potentially resolve this issue, you could try the following steps: 1. Update your Nuxt project dependencies to ensure you're using the latest version of ohash. 2. If you're using npm, run:
npm update ohash

npm update ohash

If you're using yarn, run:
yarn upgrade ohash

yarn upgrade ohash

3. After updating, rebuild your Nuxt project. If the issue persists after updating, it might be worth checking your Nuxt configuration and any custom implementations that might be interfacing with ohash. If you continue to encounter this error, I recommend reporting it as an issue on the Nuxt GitHub repository, providing details about your Nuxt version, configuration, and a minimal reproduction of the error. Remember, always backup your project before making any significant changes or updates. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai8h ago
<@252212996334551040> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
Frox
FroxOP8h ago
Ok the issue is the new update of h3 https://github.com/unjs/h3/releases Downgrading to 1.15.0 resolved it. But the thing is nitro uses h3 as dep: "h3": "^1.15.0",
GitHub
Releases · unjs/h3
⚡️ Minimal H(TTP) framework built for high performance and portability - unjs/h3
Frox
FroxOP6h ago
@danielroe FYI @pi0
pi0
pi05h ago
@Frox what version of nitro are you using? please report it as an issue if you can with reproduction to nitro repo
Frox
FroxOP5h ago
Hi @pi0 Thank you for response: I use nuxt: 3.15.4 Which uses "nitropack": "^2.10.4", I have installed version: "node_modules/nitropack": { "version": "2.10.4", Before it was installing h3: 1.15.0 But Today I had to delete package-lock.json And h3: 1.15.1 was installed and causing this issue as a workaround i locked h3 to 1.15.0 becuase was affecting production

Did you find this page helpful?