Deploying WebApp with Next/Now












0















OS: Debian 9 (stretch)



Saved Global npm install:




  • react@16.7.0


  • react-dom@16.7.0


  • next@7.0.2



Building a static webapp with Next framework, npm run dev works fine in localhost:3000 with package.json:



"scripts": {
"dev": "next",
"build": "next build",
"start": "next start"


When building for deploy alone with npm run build this happens:



> Failed to build { Error: (client) ./pages/index.js Module not found: Error: Can't resolve 'react' in 'path/to/pages' (......) }
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! arcfsoon@1.0.0 build: `next build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the arcfsoon@1.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /home/jp/.npm/_logs/2019-01-19T13_55_25_781Z-debug.log


I managed to build it yesterday, by reinstalling all the tech pile and giving su permission to my user (solution that's not working today again...). But when deployed with now, somehow there's a problem with the path to index.js, because the url now access can't find "./pages/index.js" and when redirected it displays the index.js in plain text instead of render the code.



SSR maybe? Trying to get my head around all this...



The same project was builded in a macOsX and deployed also with now and things worked perfectly.



So, what the hell mannn?



Installed and re-installed all the libs and main techs. Everything under the user and with suited priviledges.
Recriated everything from zero in new location.
Studied Next and Now's docs, as long as React's...



The closest I got to resolve the react module was with
https://webpack.js.org/configuration/resolve/, but there's not a



module.exports = {
//...
resolve: {
module: ['react']
}
};


or something like that.



After all the troubleshooting, my logic is:



1 The code is fine, as it compiles and runs smoothly on other stations;



2 Maybe there's something to do with my compilation in Debian/Linux;



Can't go any further. Any help, thanks a lot.










share|improve this question























  • Is React one of the project's dependencies (i.e. specified in the dependencies section of your project's package.json) or installed globally (i.e. by running npm install --global react)?

    – Itai Steinherz
    Jan 19 at 17:03













  • "dependencies": { "next": "^7.0.2", "react": "^16.7.0", <- npm init creates it, already changed to "latest" in troubleshooting, didn't work "react-dom": "^16.7.0" } It was installed by running "npm i -s next react react-dom", but already tried with "npm i --save --global next react react-dom"...

    – João Pedro LPS
    Jan 21 at 12:35


















0















OS: Debian 9 (stretch)



Saved Global npm install:




  • react@16.7.0


  • react-dom@16.7.0


  • next@7.0.2



Building a static webapp with Next framework, npm run dev works fine in localhost:3000 with package.json:



"scripts": {
"dev": "next",
"build": "next build",
"start": "next start"


When building for deploy alone with npm run build this happens:



> Failed to build { Error: (client) ./pages/index.js Module not found: Error: Can't resolve 'react' in 'path/to/pages' (......) }
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! arcfsoon@1.0.0 build: `next build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the arcfsoon@1.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /home/jp/.npm/_logs/2019-01-19T13_55_25_781Z-debug.log


I managed to build it yesterday, by reinstalling all the tech pile and giving su permission to my user (solution that's not working today again...). But when deployed with now, somehow there's a problem with the path to index.js, because the url now access can't find "./pages/index.js" and when redirected it displays the index.js in plain text instead of render the code.



SSR maybe? Trying to get my head around all this...



The same project was builded in a macOsX and deployed also with now and things worked perfectly.



So, what the hell mannn?



Installed and re-installed all the libs and main techs. Everything under the user and with suited priviledges.
Recriated everything from zero in new location.
Studied Next and Now's docs, as long as React's...



The closest I got to resolve the react module was with
https://webpack.js.org/configuration/resolve/, but there's not a



module.exports = {
//...
resolve: {
module: ['react']
}
};


or something like that.



After all the troubleshooting, my logic is:



1 The code is fine, as it compiles and runs smoothly on other stations;



2 Maybe there's something to do with my compilation in Debian/Linux;



Can't go any further. Any help, thanks a lot.










share|improve this question























  • Is React one of the project's dependencies (i.e. specified in the dependencies section of your project's package.json) or installed globally (i.e. by running npm install --global react)?

    – Itai Steinherz
    Jan 19 at 17:03













  • "dependencies": { "next": "^7.0.2", "react": "^16.7.0", <- npm init creates it, already changed to "latest" in troubleshooting, didn't work "react-dom": "^16.7.0" } It was installed by running "npm i -s next react react-dom", but already tried with "npm i --save --global next react react-dom"...

    – João Pedro LPS
    Jan 21 at 12:35
















0












0








0








OS: Debian 9 (stretch)



Saved Global npm install:




  • react@16.7.0


  • react-dom@16.7.0


  • next@7.0.2



Building a static webapp with Next framework, npm run dev works fine in localhost:3000 with package.json:



"scripts": {
"dev": "next",
"build": "next build",
"start": "next start"


When building for deploy alone with npm run build this happens:



> Failed to build { Error: (client) ./pages/index.js Module not found: Error: Can't resolve 'react' in 'path/to/pages' (......) }
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! arcfsoon@1.0.0 build: `next build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the arcfsoon@1.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /home/jp/.npm/_logs/2019-01-19T13_55_25_781Z-debug.log


I managed to build it yesterday, by reinstalling all the tech pile and giving su permission to my user (solution that's not working today again...). But when deployed with now, somehow there's a problem with the path to index.js, because the url now access can't find "./pages/index.js" and when redirected it displays the index.js in plain text instead of render the code.



SSR maybe? Trying to get my head around all this...



The same project was builded in a macOsX and deployed also with now and things worked perfectly.



So, what the hell mannn?



Installed and re-installed all the libs and main techs. Everything under the user and with suited priviledges.
Recriated everything from zero in new location.
Studied Next and Now's docs, as long as React's...



The closest I got to resolve the react module was with
https://webpack.js.org/configuration/resolve/, but there's not a



module.exports = {
//...
resolve: {
module: ['react']
}
};


or something like that.



After all the troubleshooting, my logic is:



1 The code is fine, as it compiles and runs smoothly on other stations;



2 Maybe there's something to do with my compilation in Debian/Linux;



Can't go any further. Any help, thanks a lot.










share|improve this question














OS: Debian 9 (stretch)



Saved Global npm install:




  • react@16.7.0


  • react-dom@16.7.0


  • next@7.0.2



Building a static webapp with Next framework, npm run dev works fine in localhost:3000 with package.json:



"scripts": {
"dev": "next",
"build": "next build",
"start": "next start"


When building for deploy alone with npm run build this happens:



> Failed to build { Error: (client) ./pages/index.js Module not found: Error: Can't resolve 'react' in 'path/to/pages' (......) }
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! arcfsoon@1.0.0 build: `next build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the arcfsoon@1.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /home/jp/.npm/_logs/2019-01-19T13_55_25_781Z-debug.log


I managed to build it yesterday, by reinstalling all the tech pile and giving su permission to my user (solution that's not working today again...). But when deployed with now, somehow there's a problem with the path to index.js, because the url now access can't find "./pages/index.js" and when redirected it displays the index.js in plain text instead of render the code.



SSR maybe? Trying to get my head around all this...



The same project was builded in a macOsX and deployed also with now and things worked perfectly.



So, what the hell mannn?



Installed and re-installed all the libs and main techs. Everything under the user and with suited priviledges.
Recriated everything from zero in new location.
Studied Next and Now's docs, as long as React's...



The closest I got to resolve the react module was with
https://webpack.js.org/configuration/resolve/, but there's not a



module.exports = {
//...
resolve: {
module: ['react']
}
};


or something like that.



After all the troubleshooting, my logic is:



1 The code is fine, as it compiles and runs smoothly on other stations;



2 Maybe there's something to do with my compilation in Debian/Linux;



Can't go any further. Any help, thanks a lot.







linux debian javascript node.js






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jan 19 at 15:46









João Pedro LPSJoão Pedro LPS

12




12













  • Is React one of the project's dependencies (i.e. specified in the dependencies section of your project's package.json) or installed globally (i.e. by running npm install --global react)?

    – Itai Steinherz
    Jan 19 at 17:03













  • "dependencies": { "next": "^7.0.2", "react": "^16.7.0", <- npm init creates it, already changed to "latest" in troubleshooting, didn't work "react-dom": "^16.7.0" } It was installed by running "npm i -s next react react-dom", but already tried with "npm i --save --global next react react-dom"...

    – João Pedro LPS
    Jan 21 at 12:35





















  • Is React one of the project's dependencies (i.e. specified in the dependencies section of your project's package.json) or installed globally (i.e. by running npm install --global react)?

    – Itai Steinherz
    Jan 19 at 17:03













  • "dependencies": { "next": "^7.0.2", "react": "^16.7.0", <- npm init creates it, already changed to "latest" in troubleshooting, didn't work "react-dom": "^16.7.0" } It was installed by running "npm i -s next react react-dom", but already tried with "npm i --save --global next react react-dom"...

    – João Pedro LPS
    Jan 21 at 12:35



















Is React one of the project's dependencies (i.e. specified in the dependencies section of your project's package.json) or installed globally (i.e. by running npm install --global react)?

– Itai Steinherz
Jan 19 at 17:03







Is React one of the project's dependencies (i.e. specified in the dependencies section of your project's package.json) or installed globally (i.e. by running npm install --global react)?

– Itai Steinherz
Jan 19 at 17:03















"dependencies": { "next": "^7.0.2", "react": "^16.7.0", <- npm init creates it, already changed to "latest" in troubleshooting, didn't work "react-dom": "^16.7.0" } It was installed by running "npm i -s next react react-dom", but already tried with "npm i --save --global next react react-dom"...

– João Pedro LPS
Jan 21 at 12:35







"dependencies": { "next": "^7.0.2", "react": "^16.7.0", <- npm init creates it, already changed to "latest" in troubleshooting, didn't work "react-dom": "^16.7.0" } It was installed by running "npm i -s next react react-dom", but already tried with "npm i --save --global next react react-dom"...

– João Pedro LPS
Jan 21 at 12:35












1 Answer
1






active

oldest

votes


















0














So... 24 days later...



The answer is in the now's doc (well hidden) witch is as follows:



"However, if you define a builds step, Now will only include the outputs that the Builders produce in the resulting deployment."



So, if I define a builder like: https://zeit.co/docs/v2/deployments/official-builders/next-js-now-next/



IT MAGICALLY WORKS!



There are a few builders ready for your preffered framework, in my case Now/Next.



SOLUTION:
2 files created:



next.config.js



module.exports = {
target: 'serverless'
}


now.json



{
"version": 2,
"builds": [{ "src": "next.config.js", "use": "@now/next" }]
}


Check https://zeit.co/docs/v2/deployments/builds/#sources-and-outputs for more info.






share|improve this answer























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "3"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1396105%2fdeploying-webapp-with-next-now%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    So... 24 days later...



    The answer is in the now's doc (well hidden) witch is as follows:



    "However, if you define a builds step, Now will only include the outputs that the Builders produce in the resulting deployment."



    So, if I define a builder like: https://zeit.co/docs/v2/deployments/official-builders/next-js-now-next/



    IT MAGICALLY WORKS!



    There are a few builders ready for your preffered framework, in my case Now/Next.



    SOLUTION:
    2 files created:



    next.config.js



    module.exports = {
    target: 'serverless'
    }


    now.json



    {
    "version": 2,
    "builds": [{ "src": "next.config.js", "use": "@now/next" }]
    }


    Check https://zeit.co/docs/v2/deployments/builds/#sources-and-outputs for more info.






    share|improve this answer




























      0














      So... 24 days later...



      The answer is in the now's doc (well hidden) witch is as follows:



      "However, if you define a builds step, Now will only include the outputs that the Builders produce in the resulting deployment."



      So, if I define a builder like: https://zeit.co/docs/v2/deployments/official-builders/next-js-now-next/



      IT MAGICALLY WORKS!



      There are a few builders ready for your preffered framework, in my case Now/Next.



      SOLUTION:
      2 files created:



      next.config.js



      module.exports = {
      target: 'serverless'
      }


      now.json



      {
      "version": 2,
      "builds": [{ "src": "next.config.js", "use": "@now/next" }]
      }


      Check https://zeit.co/docs/v2/deployments/builds/#sources-and-outputs for more info.






      share|improve this answer


























        0












        0








        0







        So... 24 days later...



        The answer is in the now's doc (well hidden) witch is as follows:



        "However, if you define a builds step, Now will only include the outputs that the Builders produce in the resulting deployment."



        So, if I define a builder like: https://zeit.co/docs/v2/deployments/official-builders/next-js-now-next/



        IT MAGICALLY WORKS!



        There are a few builders ready for your preffered framework, in my case Now/Next.



        SOLUTION:
        2 files created:



        next.config.js



        module.exports = {
        target: 'serverless'
        }


        now.json



        {
        "version": 2,
        "builds": [{ "src": "next.config.js", "use": "@now/next" }]
        }


        Check https://zeit.co/docs/v2/deployments/builds/#sources-and-outputs for more info.






        share|improve this answer













        So... 24 days later...



        The answer is in the now's doc (well hidden) witch is as follows:



        "However, if you define a builds step, Now will only include the outputs that the Builders produce in the resulting deployment."



        So, if I define a builder like: https://zeit.co/docs/v2/deployments/official-builders/next-js-now-next/



        IT MAGICALLY WORKS!



        There are a few builders ready for your preffered framework, in my case Now/Next.



        SOLUTION:
        2 files created:



        next.config.js



        module.exports = {
        target: 'serverless'
        }


        now.json



        {
        "version": 2,
        "builds": [{ "src": "next.config.js", "use": "@now/next" }]
        }


        Check https://zeit.co/docs/v2/deployments/builds/#sources-and-outputs for more info.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Feb 13 at 12:48









        João Pedro LPSJoão Pedro LPS

        12




        12






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Super User!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1396105%2fdeploying-webapp-with-next-now%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            If I really need a card on my start hand, how many mulligans make sense? [duplicate]

            Alcedinidae

            Can an atomic nucleus contain both particles and antiparticles? [duplicate]