NEM SDK Discussion

I will remember that , thanks for help:)

What do you get if you console.log nem.model.nodes.defaultTestnet and nem.model.nodes.defaultPort?

console.log(nem.model.nodes.defaultTesnet); ==> undefined
console.log(nem.model.nodes.defaultPort); ===> 7890

There is the issue. Looks like you have a spelling error in defaultTesnet. It should be defaultTestnet. Is this spelling error in the endpoint statement as well?

not at home currently, but in a hurry to try it. I want to cry :slight_smile: thanks
At least, I know now all the npm doc

1 Like

Confirmed Working on windows 10. I had npm installed since the previous videos that asked for it. Mistakes I made was not including block or error as function parameters. Had me stuck for a minute. Also I use google drive to sync my docs between multiple computers and when I open the workspace in another pc I still have to re-install nem-sdk on that pc. Just a heads up don’t really know why this happens but it does.

1 Like

does anyone know why my “node main.js” command would timeout and fail to give the result it gives in the video? :smiley:

Kyles-MacBook-Pro:firstNemProject kylekiss$ sudo node main.js
Password:
{ code: -1,
data:
{ Error: connect ETIMEDOUT 23.228.67.85:80
at Object._errnoException (util.js:992:11)
at _exceptionWithHostPort (util.js:1014:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1186:14)
code: ‘ETIMEDOUT’,
errno: ‘ETIMEDOUT’,
syscall: ‘connect’,
address: ‘23.228.67.85’,
port: 80 } }

1 Like

Figured it out…

the “defaultTestnet” is defined in the node.js file within nem-sdk. I went in and looked at what the address was and then discovered that there are other testnet addresses. I guess my computer had trouble connecting to the default address so I tried them all until one worked. For me, the http://192.3.61.243 address worked and I also manually typed in the port# 7890 in my code. So in the end, this is what my endpoint looks like now

let endpoint = nem.model.objects.create(“endpoint”)(“http://192.3.61.243”, 7890);

1 Like

i was having the same issue.

Do you also have an antivirus installed?

yes, i do. i turned it off and i still cant install nem-sdk. Its asking for hoek update.

C:\Users\123>dir
Volume in drive C has no label.
Volume Serial Number is A44F-425C

Directory of C:\Users\123

11/26/2018 12:32 PM .
11/26/2018 12:32 PM …
11/24/2018 01:48 PM .atom
10/17/2018 04:26 PM 18 .bash_history
09/25/2018 04:58 PM .config
11/26/2018 05:32 PM 51 .node_repl_history
11/15/2018 08:07 PM 3D Objects
10/15/2018 12:08 PM Apple
11/15/2018 08:07 PM Contacts
11/21/2018 11:32 AM Desktop
11/16/2018 09:32 AM Documents
11/23/2018 04:09 PM Downloads
11/15/2018 08:07 PM Favorites
11/27/2018 09:54 PM firstnemproject
09/21/2018 02:47 PM Intel
11/15/2018 08:07 PM Links
11/15/2018 08:07 PM Music
11/26/2018 12:32 PM node_modules
11/27/2018 07:58 AM OneDrive
11/26/2018 12:32 PM 289,427 package-lock.json
11/15/2018 08:07 PM Pictures
11/24/2018 01:47 PM project
11/15/2018 08:07 PM Saved Games
11/15/2018 08:07 PM Searches
11/15/2018 08:07 PM Videos
3 File(s) 289,496 bytes
22 Dir(s) 442,298,859,520 bytes free

C:\Users\123>npm install nem-sdk

[email protected] postinstall C:\Users\123\node_modules\nem-sdk
npm run build

[email protected] build C:\Users\123\node_modules\nem-sdk
babel src --presets babel-preset-es2015 --out-dir build --source-maps

src\com\requests\account.js -> build\com\requests\account.js
src\com\requests\apostille.js -> build\com\requests\apostille.js
src\com\requests\chain.js -> build\com\requests\chain.js
src\com\requests\endpoint.js -> build\com\requests\endpoint.js
src\com\requests\headers.js -> build\com\requests\headers.js
src\com\requests\index.js -> build\com\requests\index.js
src\com\requests\market.js -> build\com\requests\market.js
src\com\requests\mosaic.js -> build\com\requests\mosaic.js
src\com\requests\namespace.js -> build\com\requests\namespace.js
src\com\requests\send.js -> build\com\requests\send.js
src\com\requests\supernodes.js -> build\com\requests\supernodes.js
src\com\requests\transaction.js -> build\com\requests\transaction.js
src\com\websockets\account.js -> build\com\websockets\account.js
src\com\websockets\chain.js -> build\com\websockets\chain.js
src\com\websockets\connector.js -> build\com\websockets\connector.js
src\com\websockets\errors.js -> build\com\websockets\errors.js
src\com\websockets\index.js -> build\com\websockets\index.js
src\crypto\cryptoHelpers.js -> build\crypto\cryptoHelpers.js
src\crypto\keyPair.js -> build\crypto\keyPair.js
src\external\nacl-fast.js -> build\external\nacl-fast.js
src\external\sockjs-0.3.4.js -> build\external\sockjs-0.3.4.js
src\external\stomp.js -> build\external\stomp.js
src\index.js -> build\index.js
src\model\address.js -> build\model\address.js
src\model\apostille.js -> build\model\apostille.js
src\model\fees.js -> build\model\fees.js
src\model\network.js -> build\model\network.js
src\model\nodes.js -> build\model\nodes.js
src\model\objects\account.js -> build\model\objects\account.js
src\model\objects\miscellaneous.js -> build\model\objects\miscellaneous.js
src\model\objects\mosaic.js -> build\model\objects\mosaic.js
src\model\objects\qr.js -> build\model\objects\qr.js
src\model\objects\transactions.js -> build\model\objects\transactions.js
src\model\objects\wallet.js -> build\model\objects\wallet.js
src\model\objects.js -> build\model\objects.js
src\model\sinks.js -> build\model\sinks.js
src\model\transactions\importanceTransferTransaction.js -> build\model\transactions\importanceTransferTransaction.js
src\model\transactions\message.js -> build\model\transactions\message.js
src\model\transactions\mosaicDefinitionTransaction.js -> build\model\transactions\mosaicDefinitionTransaction.js
src\model\transactions\mosaicSupplyChange.js -> build\model\transactions\mosaicSupplyChange.js
src\model\transactions\multisigAggregateModificationTransaction.js -> build\model\transactions\multisigAggregateModificationTransaction.js
src\model\transactions\multisigWrapper.js -> build\model\transactions\multisigWrapper.js
src\model\transactions\namespaceProvisionTransaction.js -> build\model\transactions\namespaceProvisionTransaction.js
src\model\transactions\send.js -> build\model\transactions\send.js
src\model\transactions\signatureTransaction.js -> build\model\transactions\signatureTransaction.js
src\model\transactions\transferTransaction.js -> build\model\transactions\transferTransaction.js
src\model\transactions.js -> build\model\transactions.js
src\model\transactionTypes.js -> build\model\transactionTypes.js
src\model\wallet.js -> build\model\wallet.js
src\utils\convert.js -> build\utils\convert.js
src\utils\format.js -> build\utils\format.js
src\utils\helpers.js -> build\utils\helpers.js
src\utils\nty.js -> build\utils\nty.js
src\utils\serialization.js -> build\utils\serialization.js
npm WARN saveError ENOENT: no such file or directory, open ‘C:\Users\123\package.json’
npm WARN enoent ENOENT: no such file or directory, open ‘C:\Users\123\package.json’
npm WARN 123 No description
npm WARN 123 No repository field.
npm WARN 123 No README data
npm WARN 123 No license field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {“os”:“darwin”,“arch”:“any”} (current: {“os”:“win32”,“arch”:“x64”})

  • [email protected]
    updated 1 package and audited 17256 packages in 37.878s
    found 30 vulnerabilities (2 low, 21 moderate, 7 high)
    run npm audit fix to fix them, or npm audit for details

C:\Users\123>

I don’t see the error. Could you clarify and post the error message? Not all the output.

Microsoft Windows [Version 10.0.17134.407]
© 2018 Microsoft Corporation. All rights reserved.

C:\Users\123>npm install nem-sdk

[email protected] postinstall C:\Users\123\node_modules\nem-sdk
npm run build

[email protected] build C:\Users\123\node_modules\nem-sdk
babel src --presets babel-preset-es2015 --out-dir build --source-maps

src\com\requests\account.js -> build\com\requests\account.js
src\com\requests\apostille.js -> build\com\requests\apostille.js
src\com\requests\chain.js -> build\com\requests\chain.js
src\com\requests\endpoint.js -> build\com\requests\endpoint.js
src\com\requests\headers.js -> build\com\requests\headers.js
src\com\requests\index.js -> build\com\requests\index.js
src\com\requests\market.js -> build\com\requests\market.js
src\com\requests\mosaic.js -> build\com\requests\mosaic.js
src\com\requests\namespace.js -> build\com\requests\namespace.js
src\com\requests\send.js -> build\com\requests\send.js
src\com\requests\supernodes.js -> build\com\requests\supernodes.js
src\com\requests\transaction.js -> build\com\requests\transaction.js
src\com\websockets\account.js -> build\com\websockets\account.js
src\com\websockets\chain.js -> build\com\websockets\chain.js
src\com\websockets\connector.js -> build\com\websockets\connector.js
src\com\websockets\errors.js -> build\com\websockets\errors.js
src\com\websockets\index.js -> build\com\websockets\index.js
src\crypto\cryptoHelpers.js -> build\crypto\cryptoHelpers.js
src\crypto\keyPair.js -> build\crypto\keyPair.js
src\external\nacl-fast.js -> build\external\nacl-fast.js
src\external\sockjs-0.3.4.js -> build\external\sockjs-0.3.4.js
src\external\stomp.js -> build\external\stomp.js
src\index.js -> build\index.js
src\model\address.js -> build\model\address.js
src\model\apostille.js -> build\model\apostille.js
src\model\fees.js -> build\model\fees.js
src\model\network.js -> build\model\network.js
src\model\nodes.js -> build\model\nodes.js
src\model\objects\account.js -> build\model\objects\account.js
src\model\objects\miscellaneous.js -> build\model\objects\miscellaneous.js
src\model\objects\mosaic.js -> build\model\objects\mosaic.js
src\model\objects\qr.js -> build\model\objects\qr.js
src\model\objects\transactions.js -> build\model\objects\transactions.js
src\model\objects\wallet.js -> build\model\objects\wallet.js
src\model\objects.js -> build\model\objects.js
src\model\sinks.js -> build\model\sinks.js
src\model\transactions\importanceTransferTransaction.js -> build\model\transactions\importanceTransferTransaction.js
src\model\transactions\message.js -> build\model\transactions\message.js
src\model\transactions\mosaicDefinitionTransaction.js -> build\model\transactions\mosaicDefinitionTransaction.js
src\model\transactions\mosaicSupplyChange.js -> build\model\transactions\mosaicSupplyChange.js
src\model\transactions\multisigAggregateModificationTransaction.js -> build\model\transactions\multisigAggregateModificationTransaction.js
src\model\transactions\multisigWrapper.js -> build\model\transactions\multisigWrapper.js
src\model\transactions\namespaceProvisionTransaction.js -> build\model\transactions\namespaceProvisionTransaction.js
src\model\transactions\send.js -> build\model\transactions\send.js
src\model\transactions\signatureTransaction.js -> build\model\transactions\signatureTransaction.js
src\model\transactions\transferTransaction.js -> build\model\transactions\transferTransaction.js
src\model\transactions.js -> build\model\transactions.js
src\model\transactionTypes.js -> build\model\transactionTypes.js
src\model\wallet.js -> build\model\wallet.js
src\utils\convert.js -> build\utils\convert.js
src\utils\format.js -> build\utils\format.js
src\utils\helpers.js -> build\utils\helpers.js
src\utils\nty.js -> build\utils\nty.js
src\utils\serialization.js -> build\utils\serialization.js
npm WARN saveError ENOENT: no such file or directory, open ‘C:\Users\123\package.json’
npm WARN enoent ENOENT: no such file or directory, open ‘C:\Users\123\package.json’
npm WARN 123 No description
npm WARN 123 No repository field.
npm WARN 123 No README data
npm WARN 123 No license field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {“os”:“darwin”,“arch”:“any”} (current: {“os”:“win32”,“arch”:“x64”})

  • [email protected]
    updated 1 package and audited 17256 packages in 48.594s
    found 30 vulnerabilities (2 low, 21 moderate, 7 high)
    run npm audit fix to fix them, or npm audit for details

Thats what i get when i type “npm install nem-sdk”.

crosoft Windows [Version 10.0.17134.407]
© 2018 Microsoft Corporation. All rights reserved.

C:\Users\123>clear
‘clear’ is not recognized as an internal or external command,
operable program or batch file.

C:\Users\123>node main.js
module.js:550
throw err;
^

Error: Cannot find module ‘C:\Users\123\main.js’
at Function.Module._resolveFilename (module.js:548:15)
at Function.Module._load (module.js:475:25)
at Function.Module.runMain (module.js:694:10)
at startup (bootstrap_node.js:204:16)
at bootstrap_node.js:625:3

C:\Users\123>node main.js
module.js:550
throw err;
^

Error: Cannot find module ‘C:\Users\123\main.js’
at Function.Module._resolveFilename (module.js:548:15)
at Function.Module._load (module.js:475:25)
at Function.Module.runMain (module.js:694:10)
at startup (bootstrap_node.js:204:16)
at bootstrap_node.js:625:3

I don’t see any error in this. Looks fine to me.

Where is your file main.js located?