Require is Undefined










-2














I am trying to write a web application to work with with Tumblr api. I have already used npm and installed both globally and in the file itself: browesrify, tumblr and tumblr.js. whenever I upload the file to my server which runs on Netlify I get the error that require is undefined.



/* global $ document console len alert require */


// Authenticate via OAuth
var tumblr = require('tumblr');


Here is my error:



script.js:5 Uncaught ReferenceError: require is not defined


I am aware of the fact that this question has been asked before and I have gone through all instances of these types of questions and none of the solutions have worked for me so perhaps something has been updated in one or more of the frameworks.










share|improve this question





















  • Wild speculation: You are uploading your raw source files and not the output of browserify. It's really hard to tell given the level of information in the question.
    – Quentin
    Nov 12 at 13:16










  • How would I get and upload the output of browserify instead?
    – Jason Rogers
    Nov 12 at 13:18










  • It's just a file … output to wherever you told browserify to put it.
    – Quentin
    Nov 12 at 13:18










  • Perhaps I am not understanding browserify could you explain further please?
    – Jason Rogers
    Nov 12 at 13:19










  • browserify has a perfectly good website if you want an introduction to it. There is no point in me reproducing it here.
    – Quentin
    Nov 12 at 13:20















-2














I am trying to write a web application to work with with Tumblr api. I have already used npm and installed both globally and in the file itself: browesrify, tumblr and tumblr.js. whenever I upload the file to my server which runs on Netlify I get the error that require is undefined.



/* global $ document console len alert require */


// Authenticate via OAuth
var tumblr = require('tumblr');


Here is my error:



script.js:5 Uncaught ReferenceError: require is not defined


I am aware of the fact that this question has been asked before and I have gone through all instances of these types of questions and none of the solutions have worked for me so perhaps something has been updated in one or more of the frameworks.










share|improve this question





















  • Wild speculation: You are uploading your raw source files and not the output of browserify. It's really hard to tell given the level of information in the question.
    – Quentin
    Nov 12 at 13:16










  • How would I get and upload the output of browserify instead?
    – Jason Rogers
    Nov 12 at 13:18










  • It's just a file … output to wherever you told browserify to put it.
    – Quentin
    Nov 12 at 13:18










  • Perhaps I am not understanding browserify could you explain further please?
    – Jason Rogers
    Nov 12 at 13:19










  • browserify has a perfectly good website if you want an introduction to it. There is no point in me reproducing it here.
    – Quentin
    Nov 12 at 13:20













-2












-2








-2







I am trying to write a web application to work with with Tumblr api. I have already used npm and installed both globally and in the file itself: browesrify, tumblr and tumblr.js. whenever I upload the file to my server which runs on Netlify I get the error that require is undefined.



/* global $ document console len alert require */


// Authenticate via OAuth
var tumblr = require('tumblr');


Here is my error:



script.js:5 Uncaught ReferenceError: require is not defined


I am aware of the fact that this question has been asked before and I have gone through all instances of these types of questions and none of the solutions have worked for me so perhaps something has been updated in one or more of the frameworks.










share|improve this question













I am trying to write a web application to work with with Tumblr api. I have already used npm and installed both globally and in the file itself: browesrify, tumblr and tumblr.js. whenever I upload the file to my server which runs on Netlify I get the error that require is undefined.



/* global $ document console len alert require */


// Authenticate via OAuth
var tumblr = require('tumblr');


Here is my error:



script.js:5 Uncaught ReferenceError: require is not defined


I am aware of the fact that this question has been asked before and I have gone through all instances of these types of questions and none of the solutions have worked for me so perhaps something has been updated in one or more of the frameworks.







javascript node.js require node-modules netlify






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 12 at 13:14









Jason Rogers

11




11











  • Wild speculation: You are uploading your raw source files and not the output of browserify. It's really hard to tell given the level of information in the question.
    – Quentin
    Nov 12 at 13:16










  • How would I get and upload the output of browserify instead?
    – Jason Rogers
    Nov 12 at 13:18










  • It's just a file … output to wherever you told browserify to put it.
    – Quentin
    Nov 12 at 13:18










  • Perhaps I am not understanding browserify could you explain further please?
    – Jason Rogers
    Nov 12 at 13:19










  • browserify has a perfectly good website if you want an introduction to it. There is no point in me reproducing it here.
    – Quentin
    Nov 12 at 13:20
















  • Wild speculation: You are uploading your raw source files and not the output of browserify. It's really hard to tell given the level of information in the question.
    – Quentin
    Nov 12 at 13:16










  • How would I get and upload the output of browserify instead?
    – Jason Rogers
    Nov 12 at 13:18










  • It's just a file … output to wherever you told browserify to put it.
    – Quentin
    Nov 12 at 13:18










  • Perhaps I am not understanding browserify could you explain further please?
    – Jason Rogers
    Nov 12 at 13:19










  • browserify has a perfectly good website if you want an introduction to it. There is no point in me reproducing it here.
    – Quentin
    Nov 12 at 13:20















Wild speculation: You are uploading your raw source files and not the output of browserify. It's really hard to tell given the level of information in the question.
– Quentin
Nov 12 at 13:16




Wild speculation: You are uploading your raw source files and not the output of browserify. It's really hard to tell given the level of information in the question.
– Quentin
Nov 12 at 13:16












How would I get and upload the output of browserify instead?
– Jason Rogers
Nov 12 at 13:18




How would I get and upload the output of browserify instead?
– Jason Rogers
Nov 12 at 13:18












It's just a file … output to wherever you told browserify to put it.
– Quentin
Nov 12 at 13:18




It's just a file … output to wherever you told browserify to put it.
– Quentin
Nov 12 at 13:18












Perhaps I am not understanding browserify could you explain further please?
– Jason Rogers
Nov 12 at 13:19




Perhaps I am not understanding browserify could you explain further please?
– Jason Rogers
Nov 12 at 13:19












browserify has a perfectly good website if you want an introduction to it. There is no point in me reproducing it here.
– Quentin
Nov 12 at 13:20




browserify has a perfectly good website if you want an introduction to it. There is no point in me reproducing it here.
– Quentin
Nov 12 at 13:20












1 Answer
1






active

oldest

votes


















0














Netlify will not have Browserify installed on a global scope in npm, so you should set it up in your local project. You set it up using the global install locally, so it works on your local environment.



Make sure you have your package.json setup correctly and it exists.



Install browserify as a development dependency.



$ npm install browserify --save-dev


Add a build script command to your package.json



 "scripts": 
"build": "browserify main.js -o bundle.js"
,


Note Your command should use the correct browserify command.



Use npm run build as your Netlify build command.






share|improve this answer




















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    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%2fstackoverflow.com%2fquestions%2f53262956%2frequire-is-undefined%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














    Netlify will not have Browserify installed on a global scope in npm, so you should set it up in your local project. You set it up using the global install locally, so it works on your local environment.



    Make sure you have your package.json setup correctly and it exists.



    Install browserify as a development dependency.



    $ npm install browserify --save-dev


    Add a build script command to your package.json



     "scripts": 
    "build": "browserify main.js -o bundle.js"
    ,


    Note Your command should use the correct browserify command.



    Use npm run build as your Netlify build command.






    share|improve this answer

























      0














      Netlify will not have Browserify installed on a global scope in npm, so you should set it up in your local project. You set it up using the global install locally, so it works on your local environment.



      Make sure you have your package.json setup correctly and it exists.



      Install browserify as a development dependency.



      $ npm install browserify --save-dev


      Add a build script command to your package.json



       "scripts": 
      "build": "browserify main.js -o bundle.js"
      ,


      Note Your command should use the correct browserify command.



      Use npm run build as your Netlify build command.






      share|improve this answer























        0












        0








        0






        Netlify will not have Browserify installed on a global scope in npm, so you should set it up in your local project. You set it up using the global install locally, so it works on your local environment.



        Make sure you have your package.json setup correctly and it exists.



        Install browserify as a development dependency.



        $ npm install browserify --save-dev


        Add a build script command to your package.json



         "scripts": 
        "build": "browserify main.js -o bundle.js"
        ,


        Note Your command should use the correct browserify command.



        Use npm run build as your Netlify build command.






        share|improve this answer












        Netlify will not have Browserify installed on a global scope in npm, so you should set it up in your local project. You set it up using the global install locally, so it works on your local environment.



        Make sure you have your package.json setup correctly and it exists.



        Install browserify as a development dependency.



        $ npm install browserify --save-dev


        Add a build script command to your package.json



         "scripts": 
        "build": "browserify main.js -o bundle.js"
        ,


        Note Your command should use the correct browserify command.



        Use npm run build as your Netlify build command.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 12 at 16:28









        talves

        5,46311134




        5,46311134



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • 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.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • 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%2fstackoverflow.com%2fquestions%2f53262956%2frequire-is-undefined%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







            這個網誌中的熱門文章

            How to read a connectionString WITH PROVIDER in .NET Core?

            Node.js Script on GitHub Pages or Amazon S3

            Museum of Modern and Contemporary Art of Trento and Rovereto