Error: Cannot find module 'fastify'

i had this issue before out of no where but when i couldn’t to do i started a new projected and pasted all my files today am also faced with the same issue although i think it started due to the update i made to node from version 14 to 16 i also came across a similar issue to mine but it was solved and it was not clear how

https://support.glitch.com/t/cannot-find-module-this-morning-when-last-night-it-worked/66162/7

The user other thread in the other thread was advised to contact support@glitch.com - I recommend you do that too, they should be able to help.

1 Like

Already did but today is sunday

Still no assistance any help

Created
Sunday at 18:31
Last activity
Yesterday at 20:06

can you check the logs to see what happens when glitch tried to install the dependencies

node v14.19.1, npm 6.14.16

10:14 PM

Installing…

10:14 PM

npm ERR! nested aliases not supported

10:14 PM

10:14 PM

npm ERR! A complete log of this run can be found in:

10:14 PM

npm ERR! /tmp/npm-cache/14.19.1/_logs/2024-09-26T19_14_38_583Z-debug.log

10:14 PM


a few seconds ago

internal/modules/cjs/loader.js:905

10:14 PM

throw err;

10:14 PM

^

10:14 PM

10:14 PM

Error: Cannot find module ‘fastify’

10:14 PM

Require stack:

10:14 PM

Jump To- /app/server.js

10:14 PM

at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)

10:14 PM

at Function.Module._load (internal/modules/cjs/loader.js:746:27)

10:14 PM

at Module.require (internal/modules/cjs/loader.js:974:19)

10:14 PM

at require (internal/modules/cjs/helpers.js:101:18)

10:14 PM

Jump Toat Object. (/app/server.js:2:17)

10:14 PM

at Module._compile (internal/modules/cjs/loader.js:1085:14)

10:14 PM

at Object.Module._extensions…js (internal/modules/cjs/loader.js:1114:10)

10:14 PM

at Module.load (internal/modules/cjs/loader.js:950:32)

10:14 PM

at Function.Module._load (internal/modules/cjs/loader.js:790:12)

10:14 PM

at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:75:12) {

10:14 PM

code: ‘MODULE_NOT_FOUND’,

10:14 PM

Jump TorequireStack: [ ‘/app/server.js’ ]

10:14 PM

}

10:14 PM

I downgraded to Node.js 14 because the issue started after upgrading to Node.js 16.so i rewinded back to see if the issue will disappear and here is the current log

I’d better look up what a nested alias even is

says it’s about having an aliased dependency that itself has an aliased dependency. an aliased dependency supposedly being

npm install <alias>@npm:<name>:

Install a package under a custom alias. Allows multiple versions of a same-name package side-by-side, more convenient import names for packages with otherwise long ones, and using git forks replacements or forked npm packages as replacements. Aliasing works only on your project and does not rename packages in transitive dependencies. …

are there any hints in the /tmp/npm-cache/…/_logs/…-debug.log file about what has all these aliases?

i checked the /tmp/npm-cache/…/_logs/…-debug.log file and it says nested aliases not supported even though package.json looks mostly fine; there are no nested aliases visible in the dependencies section, which suggests the issue might be coming from somewhere else

weird, could it be entirely within dependencies and transitive dependencies then?

Don’t know cause today i decided to migrate to express guess what

internal/modules/cjs/loader.js:905

9:13 PM

throw err;

9:13 PM

^

9:13 PM

9:13 PM

Error: Cannot find module ‘express’

9:13 PM

Require stack:

9:13 PM

Jump To- /app/server.js

9:13 PM

at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)

9:13 PM

at Function.Module._load (internal/modules/cjs/loader.js:746:27)

9:13 PM

at Module.require (internal/modules/cjs/loader.js:974:19)

9:13 PM

at require (internal/modules/cjs/helpers.js:101:18)

9:13 PM

Jump Toat Object. (/app/server.js:2:17)

9:13 PM

at Module._compile (internal/modules/cjs/loader.js:1085:14)

9:13 PM

at Object.Module._extensions…js (internal/modules/cjs/loader.js:1114:10)

9:13 PM

at Module.load (internal/modules/cjs/loader.js:950:32)

9:13 PM

at Function.Module._load (internal/modules/cjs/loader.js:790:12)

9:13 PM

at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:75:12) {

9:13 PM

code: ‘MODULE_NOT_FOUND’,

9:13 PM

Jump TorequireStack: [ ‘/app/server.js’ ]

9:13 PM

}

well the nested alias problem wasn’t necessarily in fastify’s dependency tree, so yeah the inability to get the dependencies installed ought to persist if you switch to express. in fact we should be pretty certain that the nested alias wasn’t in fastify’s dependency tree because the starter project has been able to install fastify just fine

do you have suggestions for identifying or resolving the nested alias issue in the project?

it looks like the log file will show what it’s trying to install when it encounters this. in that github issue, it was like this:

17 silly saveTree └── @reedsy/reedsy-sharedb@22.1.5
18 verbose stack Error: nested aliases not supported
18 verbose stack     at ...

and indeed the problem was with this reedsy-sharedb package and its dependency.

can you see what comes right before the error in yours

8 http fetch GET 200 https://registry.npmjs.org/fastify 506ms
9 http fetch GET 200 https://registry.npmjs.org/fastify/-/fastify-5.0.0.tgz 489ms
10 silly pacote range manifest for fastify@^5.0.0 fetched in 1094ms
11 timing stage:loadCurrentTree Completed in 1389ms
12 silly install loadIdealTree
13 silly install cloneCurrentTreeToIdealTree
14 timing stage:loadIdealTree:cloneCurrentTree Completed in 1ms
15 silly install loadShrinkwrap
16 timing stage:rollbackFailedOptional Completed in 1ms
17 timing stage:runTopLevelLifecycles Completed in 1571ms
18 silly saveTree epicmays@0.1.0
19 verbose stack Error: nested aliases not supported

However, it doesn’t specify which package or sub-package is causing the “nested aliases not supported” error. This makes it difficult to pinpoint the exact cause of the issue.

what package is this?

epicmays@0.1.0

name and version of my project oh i decided to change for privacy reasons hope you also edit

dang, so no info from that.

next idea then, remove all dependencies and add them back until this happens again

already did that i think it’s a bug on glitch side which affected all my node js projects

which dependency causes it when it’s added?

i think fastify

npm install fastify
npm ERR! nested aliases not supported

npm ERR! A complete log of this run can be found in:
npm ERR! /tmp/npm-cache/14.19.1/_logs/2024-09-27T18_58_13_840Z-debug.log