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

Import is not working in app2 #1

Open
sankaran85 opened this issue Dec 8, 2020 · 4 comments
Open

Import is not working in app2 #1

sankaran85 opened this issue Dec 8, 2020 · 4 comments

Comments

@sankaran85
Copy link

Hi,

when i try to run the app2 both console and in browser im getting below error. Please help me out.

Cannot find module 'D:extjs-exampleemoteEntry.js'tapp1.nextserverstatic
while loading "./nav" from webpack/container/reference/app1
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at module.exports.exports.modules.webpack/container/reference/app1.module.exports.res (D:\react\nextjs-example\next-mf-blogpost\app2.next\server\pages\index.js:2058:16)
at new Promise ()
at Object.webpack/container/reference/app1 (D:\react\nextjs-example\next-mf-blogpost\app2.next\server\pages\index.js:2052:18)
at webpack_require (D:\react\nextjs-example\next-mf-blogpost\app2.next\server\webpack-runtime.js:24:42)
at handleFunction (D:\react\nextjs-example\next-mf-blogpost\app2.next\server\webpack-runtime.js:173:31)
at D:\react\nextjs-example\next-mf-blogpost\app2.next\server\webpack-runtime.js:192:15 code: 'MODULE_NOT_FOUND' }
event - build page: /next/dist/pages/_error

@bchurlinov
Copy link

I am getting the same behavior. @sankaran85 did you find any way around this ?

@hamatoyogi
Copy link
Owner

I've just cloned the repo for a fresh start and re-tried it. Seems to work for me.
What version node are you trying @sankaran85 @bchurlinov?
Works for me at the moment on Node v14.7.0.

@bobum
Copy link

bobum commented Jun 24, 2021

The problem is pathing, at least on Windows. There is a require in the built index.js of app2 that isn't escaping the slashes in the path correctly and the required module thus can't be found. The \r and \n are getting treated as carriage returns and linefeeds - look at the error message and you can see it.

To fix it for me, did a manual 'yarn next build' of app 2 first.
Then I went into the index.js where the error was getting thrown and found the following path in a require

remote = require('D:\projects\next-mf-blogpost\app1\.next\server\static\runtime\remoteEntry.js')['app1']

I changed that path to:

D:\\projects\\next-mf-blogpost\\app1\\.next\\server\\static\\runtime\\remoteEntry.js

In both the TRY and CATCH blocks.

Then I did a manual start of the server by running 'yarn next start -p 3001'

And poof it worked...haven't figured out yet how to fix it during the build process - but this got it up and running locally.

@AnilDCoder
Copy link

AnilDCoder commented Nov 25, 2021

I fixed it by adding replace()

remotes: {
        // For SSR, resolve to disk path (or you can use code streaming if you have access)
        home: isServer
          ? path.resolve(
              __dirname,
              "../home/.next/server/static/runtime/remoteEntry.js"
            ).replace(/\\/g, '/')     //<=====here
          : "home", // for client, treat it as a global
      },

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

5 participants