Migrating from Sandbox to Dev

All,

I’ve successfully run payments through the sample app with Node.js. I’m trying to migrate to development and running into. I have the site kind of working but I’m getting SSL errors. I’m running ‘npm run dev’ because I can’t seem to get ‘npm start’ to work. I am extremely new to node.js so I’m not sure what to even check. Any and all help would be greatly appreciated. Also, if there are any node.js experts out there willing to help in a consulting basis (i.e. get paid) please let me know. I’m kind of dead in the water at this point as I don’t even know where to look to resolve these issues.

Thanks,

Jeff

:wave: I’m Square Dev AI, here to help answer your question!
Based on the information you’ve provided, the following documentation will help answer your question:

Additional Documentation

Deploy the Server
Deploy the Server
Node.js SDK

If this documentation helped you find a solution, please check the box indicating that this reply solves the problem.
Otherwise one of our Developer Advocates will provide additional assistance shortly.

What errors do you get if you run npm start. I just tested our Quickstart in production and it’s working as expected. Also what the site address your using in production? :slightly_smiling_face:

Bryan,

I get a file not found package.json. I got the quick start from git hub, I think. I saw a getting started where it mentions how to start a project. It’s different from what I walked through, which was the payment quick start. I’m not at my office so I don’t have the full URL. I’ll get that later.

Jeff

Jeff

Bryan,

Is there a valid package.json file available for the card-payment quick start somewhere?

Thanks,

Jeff

If you cloned the repo it should work out of the box in both sandbox and production.

Bryan,

In the quickstart it only mentions npm run dev which is what I stuck with throughout the development. If I clone & try to run npm start I get ‘NODE_ENV’ is not recognized as an internal or external command. In package.json I see the lines included below. They both look like they’re doing the same thing though, can I just change the script to “start”: “micro --listen tcp://0.0.0.0:${PORT-3000}”? That’s a complete guess on my part.

Thanks,

Jeff

“start”: “NODE_ENV=production micro --listen tcp://0.0.0.0:${PORT-3000}”,
“start:sandbox”: “NODE_ENV=sandbox micro --listen tcp://0.0.0.0:${PORT-3000}”,

Bryan,

Alos, this is in a windows environment. I did some google searches & I saw it mentioned the variable needs to be declared in some other way but I don’t know where to put it.

Jeff

When you get that and go to http://localhost:3000/ does it work? :slightly_smiling_face:

Bryan,

I tried installing cross-env & changed the assignment to:

“start”: “cross-env NODE_ENV=production micro --listen tcp://0.0.0.0:${PORT-3000}”,

While this got rid of the NODE_ENV error it did not work. I now get an error:

code: ‘ERR_INVALID_URL’

input ‘tcp://0.0.0.0:$PORT-3000’

And no, localhost:3000 does not come up as node cannot even start.

Jeff

Did you make any changes to our example that weren’t in the instructions? :slightly_smiling_face:

No, this is the base download. I just added my auth tokens but everything else is the same. This is on a windows machine, which might make a difference. Do you have a quick start folder that will run npm start? If so, can you send it to me for testing here? The download I have from githib just doesnt work with npm start - and again npm run dev kind of works but not really over ssl. I can zip up mine and send it to you if you like. I’m thinking this is not going to work with windows servers, although I have no idea why.

Thanks,

Jeff

Bryan,

I just did a redownload of the project and didn’t change anything. I tried NPM start & get the NODE_ENV error so something is not right with this on windows machines.

Thanks,

Jeff

Hmm, I’m not really sure what to advise. It’s odd that sandbox is working but when switching to production it fails. :thinking:

Sandbox isn’t really working. I’m using npm run dev which you are not supposed to do in production. Running npm start gas never worked.

Jeff

Right, that’s expected for sandbox. Production you should be able to get npm start to work. Did you create an new .env file that’s env.production in the repo? :slightly_smiling_face:

Bryan,

I finally got npm start to work. In windows, the github repo will not work as is. I included the steps below. My next problem is I’m getting the applicationId and/or locationId is incorrect. My appID is ‘sq0idp-FtPlaW7bDH3DArwZ109kBg’ and locationId is ‘LKPBB4X4SV4FZ’. I have the env.production set as well but something is not quite right. Is there something or somewhere else I need to look/chekc?

Thanks,

Jeff

npm install cross-env (from the command prompt)

change project.json (add the cross-env prior to NODE_ENV and micro --listen)

“start”: “cross-env NODE_ENV=production cross-env micro --listen tcp://0.0.0.0:3000”,
“start:sandbox”: " cross-env NODE_ENV=sandbox cross-env micro --listen tcp://0.0.0.0:${PORT-3000}",

Hi Jeff,

It sounds like you’re encountering SSL issues while migrating to the development environment. As you’re new to Node.js, I’d recommend checking the following:

  1. Ensure that you have a valid SSL certificate configured for your development server.
  2. Check if you’re running the server over HTTPS and if it’s properly set up.
  3. Try running npm run dev with a --https flag if you’re using local certificates.

If the problem persists, I’d recommend reaching out to experienced developers or Australian web development companies that specialize in Node.js. They might be able to provide consulting support to help resolve your issues.

Feel free to let me know if you need further assistance!

Best,
Wasim tariq