Log in
Sign up
Overview Questions Answers

looper003

    Stats

    • 180 reputation
    • 76 questions asked
    • 77 answers
    • 27 selected answers
    Overview Questions Answers
    • Newest Questions 76
    "'Window' is not defined` ESLint warning in Next.js app?
    Asked 21 hours ago by looper003 · Unansweredjavascripteslintnext.js
    1
    Get a list of each file in a Git repository via the command line?
    Asked 1 year ago by looper003 · Answeredgit
    4
    Skip a test with a conditional in Cypress?
    Asked 1 year ago by looper003 · Answeredjavascriptcypres
    2
    What does this .replace(/\s+/g, " ") regular expression do?
    Asked 1 year ago by looper003 · Answeredregexjavascript
    3
    Run a Cypress test in all browsers besides Firefox?
    Asked 1 year ago by looper003 · Answeredcypressjavascript
    3
    View more →
    • Newest Answers 77
    Remove "'process' is not defined" ESLint warning in Next.js?

    You want the environment: node that includes process.

    Update the env section of your .eslintrc.js file to include it:

      env: {
        node: true,
      },
    

    Since Next.js runs code in both the browser and server (Node.js) environments, you'll want both node and browser environments:

      env: {
        node: true,
        browser: true,
      },
    
    Answered 21 hours ago by looper003
    How to add a code comment in React.js?

    Do this:

    {/* your code comment */}
    

    That should solve the issue for you.

    Answered 23 hours ago by looper003
    Redirect to a new page in getInitialProps using Next.js?

    You can use res.writeHead() to do this. This will allow you to set a new location on the response header.

    To do this, you can update your getInitialProps() function to this:

    static async getInitialProps({ query, req, res }) {
      const apiResult = await getImageByFilename(query.filename, req);
    
      if (boolean) {
        res.writeHead(302, {
          Location: "/different-page"
        });
    
        res.end();
      }
    
      return {
        data: apiResult.data,
      };
    }
    

    If the given boolean value is true, you'll be redirected to the /different-page page.

    The 302 code indicates that it's a redirect.

    Answered 9 months ago by looper003
    Stop Nodemon from restarting when a specific file is updated?

    Nodemon has an --ignore flag you can add to the nodemon command.

    Ignore a file:

    nodemon ignore lib/data.json
    

    You can also do a pattern to ignore changes in all json files:

    nodemon --ignore '*.json'
    
    Answered 9 months ago by looper003 · Selected answer
    Get the current version of Docker installed on my macOS machine?

    docker -v command works as well.

    Answered 10 months ago by looper003
    View more →
    • Terms
    • Privacy

    © 2023 Chunkks