Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nest run fails if import dto in monorepo #34

Closed
eakarpov opened this issue Dec 24, 2019 · 9 comments
Closed

nest run fails if import dto in monorepo #34

eakarpov opened this issue Dec 24, 2019 · 9 comments

Comments

@eakarpov
Copy link

Describe the bug
module.js:550
throw err;
^

Error: Cannot find module '/home/george/Documents/slovinar/server/dist/main'
at Function.Module._resolveFilename (module.js:548:15)
at Function.Module._load (module.js:475:25)
at Function.Module.runMain (module.js:694:10)
at startup (bootstrap_node.js:204:16)
at bootstrap_node.js:625:3

Expected behavior
Imported interface does not influence the build

To Reproduce
Repository URL: https://github.com/SlavDom/slovinar

Version

  • next.js: 9.1.9
  • nest: 6.7.2
  • nest-next: 9.1.1

Additional context
If I do not add a type from 'dto' folder, the run is successful, but if I add the import, it fails.

@kyle-mccarthy
Copy link
Owner

kyle-mccarthy commented Dec 24, 2019 via email

@eakarpov
Copy link
Author

@kyle-mccarthy Yes, you're right. My fault.

But one question, I run the application and the watcher gives the following feedback. Why does it try watching the /home directory and not only ui folder that I defined in the following code?

const dir = resolve(__dirname, '../../ui');
const app = Next({ dev, dir });

Watchpack Error (watcher): Error: watch /home ENOSPC Watchpack Error (watcher): Error: watch /home/george ENOSPC

@kyle-mccarthy
Copy link
Owner

kyle-mccarthy commented Dec 24, 2019 via email

@eakarpov
Copy link
Author

@kyle-mccarthy yes, it is. and the same path is in the monorepo example here.

@kyle-mccarthy
Copy link
Owner

kyle-mccarthy commented Dec 24, 2019 via email

@eakarpov
Copy link
Author

@kyle-mccarthy I run the app from server folder.

@boenrobot
Copy link
Contributor

boenrobot commented Dec 25, 2019

If I do not add a type from 'dto' folder, the run is successful, but if I add the import, it fails.

When importing dtos in the ui project, you need to explicitly import from the "src" folder, as the example does.

The reason is that Next doesn't compile TypeScript with the TypeScript compiler (that would otherwise take care of this), but it transpiles it with Babel instead.

Also, you need to do "npm build" on both "ui" and "server" before starting from "server". No need to compile "dto", as the "server" build does this for you, while "ui" doesn't need it.

The watch error is Linux specific and I only saw a similar one recently (like, two days ago) and have no idea what's causing it and how to solve it. All I can say for sure is that Windows can watch files in all repos normally through "npm dev" on the server.

@boenrobot
Copy link
Contributor

I was told (by the same colleague that showed me the aforementioned similar Linux issue) that the problem was the watcher limit was too low. A value of 16384 was sufficient for our project... Not sure if that value is needed also for the example.

You can set it (permanently) with

echo fs.inotify.max_user_watches=16384 | sudo tee -a /etc/sysctl.conf

@kyle-mccarthy
Copy link
Owner

I looked into this more and found some answers in the gatsby and jest repos that offer the same suggestion as @boenrobot, also it looks like just rebooting resolves the issue sometimes as well. Since this issue isn't really related to to nest-next I am going to close it.

Here are the relevant discussions from the other repos.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants