Ir para conteúdo

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

flyahed

NODE_MODULE_VERSION 48. This version of Node.js requires | NODE_MODULE_VERSION 64. Please try re-compiling or re-installing

Recommended Posts

It's my first Electron project, after uses the getting starter, sorry if it is something too dumb

I'm trying to automatize some stuffs i do, so my first project should be something with this lib:
http://robotjs.io/

 

But i reciving this error:


A JavaScript error occurred in the main process
Uncaught Exception:
Error: The module '/home/flyahed/electron/zezeta/node_modules/robotjs/build/Release/robotjs.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 48. This version of Node.js requires
NODE_MODULE_VERSION 64. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
    at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:166:20)
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:740:18)
    at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:166:20)
    at Module.load (internal/modules/cjs/loader.js:620:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:559:12)
    at Function.Module._load (internal/modules/cjs/loader.js:551:3)
    at Module.require (internal/modules/cjs/loader.js:658:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (/home/flyahed/electron/zezeta/node_modules/robotjs/index.js:1:170)
    at Object.<anonymous> (/home/flyahed/electron/zezeta/node_modules/robotjs/index.js:38:3)

 

 

 

---

 

What i've done:
npm install robotjs

rm -r node_modules and npm install (searching on internet i found that would be a soluctoin to the problem)

 

added this lines to my package.json, from:  (http://robotjs.io/docs/electron)

	

  "main": "index.js",
  "scripts": {
    "rebuild": "npm rebuild --runtime=electron --target=1.1.3 --disturl=https://atom.io/download/atom-shell --abi=48",
    "electron": "electron ."
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "electron": "^3.0.7"
  },
  "dependencies": {
    "robotjs": "^0.5.1"
  }

 

npm run rebuild

npm run electron

 

but the error still showing

 

 

 

Full command LOGS:


flyahed@flyahed:~/electron/autothis$ ls

index.html  index.js  package.json  package-lock.json

 

 

flyahed@flyahed:~/electron/autothis$ npm install

> robotjs@0.5.1 install /home/flyahed/electron/autothis/node_modules/robotjs
> prebuild-install || node-gyp rebuild


> electron@3.0.7 postinstall /home/flyahed/electron/autothis/node_modules/electron
> node install.js

npm WARN autothis@1.0.0 No description
npm WARN autothis@1.0.0 No repository field.

added 191 packages from 148 contributors and audited 308 packages in 3.329s
found 0 vulnerabilities

 

 

flyahed@flyahed:~/electron/autothis$ npm run rebuild

> autothis@1.0.0 rebuild /home/flyahed/electron/autothis
> npm rebuild --runtime=electron --target=1.1.3 --disturl=https://atom.io/download/atom-shell --abi=48


> robotjs@0.5.1 install /home/flyahed/electron/autothis/node_modules/robotjs
> prebuild-install || node-gyp rebuild


> electron@3.0.7 postinstall /home/flyahed/electron/autothis/node_modules/electron
> node install.js

robotjs@0.5.1 /home/flyahed/electron/autothis/node_modules/robotjs
nan@2.11.1 /home/flyahed/electron/autothis/node_modules/nan
prebuild-install@2.5.3 /home/flyahed/electron/autothis/node_modules/prebuild-install
detect-libc@1.0.3 /home/flyahed/electron/autothis/node_modules/detect-libc
expand-template@1.1.1 /home/flyahed/electron/autothis/node_modules/expand-template
github-from-package@0.0.0 /home/flyahed/electron/autothis/node_modules/github-from-package
minimist@1.2.0 /home/flyahed/electron/autothis/node_modules/minimist
mkdirp@0.5.1 /home/flyahed/electron/autothis/node_modules/mkdirp
minimist@0.0.8 /home/flyahed/electron/autothis/node_modules/mkdirp/node_modules/minimist
node-abi@2.5.0 /home/flyahed/electron/autothis/node_modules/node-abi
semver@5.6.0 /home/flyahed/electron/autothis/node_modules/semver
noop-logger@0.1.1 /home/flyahed/electron/autothis/node_modules/noop-logger
npmlog@4.1.2 /home/flyahed/electron/autothis/node_modules/npmlog
are-we-there-yet@1.1.5 /home/flyahed/electron/autothis/node_modules/are-we-there-yet
delegates@1.0.0 /home/flyahed/electron/autothis/node_modules/delegates
readable-stream@2.3.6 /home/flyahed/electron/autothis/node_modules/are-we-there-yet/node_modules/readable-stream
core-util-is@1.0.2 /home/flyahed/electron/autothis/node_modules/core-util-is
inherits@2.0.3 /home/flyahed/electron/autothis/node_modules/inherits
isarray@1.0.0 /home/flyahed/electron/autothis/node_modules/are-we-there-yet/node_modules/isarray
process-nextick-args@2.0.0 /home/flyahed/electron/autothis/node_modules/process-nextick-args
safe-buffer@5.1.2 /home/flyahed/electron/autothis/node_modules/safe-buffer
string_decoder@1.1.1 /home/flyahed/electron/autothis/node_modules/are-we-there-yet/node_modules/string_decoder
util-deprecate@1.0.2 /home/flyahed/electron/autothis/node_modules/util-deprecate
console-control-strings@1.1.0 /home/flyahed/electron/autothis/node_modules/console-control-strings
gauge@2.7.4 /home/flyahed/electron/autothis/node_modules/gauge
aproba@1.2.0 /home/flyahed/electron/autothis/node_modules/aproba
has-unicode@2.0.1 /home/flyahed/electron/autothis/node_modules/has-unicode
object-assign@4.1.1 /home/flyahed/electron/autothis/node_modules/object-assign
signal-exit@3.0.2 /home/flyahed/electron/autothis/node_modules/signal-exit
string-width@1.0.2 /home/flyahed/electron/autothis/node_modules/string-width
code-point-at@1.1.0 /home/flyahed/electron/autothis/node_modules/code-point-at
is-fullwidth-code-point@1.0.0 /home/flyahed/electron/autothis/node_modules/is-fullwidth-code-point
number-is-nan@1.0.1 /home/flyahed/electron/autothis/node_modules/number-is-nan
strip-ansi@3.0.1 /home/flyahed/electron/autothis/node_modules/strip-ansi
ansi-regex@2.1.1 /home/flyahed/electron/autothis/node_modules/ansi-regex
wide-align@1.1.3 /home/flyahed/electron/autothis/node_modules/wide-align
set-blocking@2.0.0 /home/flyahed/electron/autothis/node_modules/set-blocking
os-homedir@1.0.2 /home/flyahed/electron/autothis/node_modules/os-homedir
pump@2.0.1 /home/flyahed/electron/autothis/node_modules/pump
end-of-stream@1.4.1 /home/flyahed/electron/autothis/node_modules/end-of-stream
once@1.4.0 /home/flyahed/electron/autothis/node_modules/once
wrappy@1.0.2 /home/flyahed/electron/autothis/node_modules/wrappy
rc@1.2.8 /home/flyahed/electron/autothis/node_modules/rc
deep-extend@0.6.0 /home/flyahed/electron/autothis/node_modules/deep-extend
ini@1.3.5 /home/flyahed/electron/autothis/node_modules/ini
strip-json-comments@2.0.1 /home/flyahed/electron/autothis/node_modules/strip-json-comments
simple-get@2.8.1 /home/flyahed/electron/autothis/node_modules/simple-get
decompress-response@3.3.0 /home/flyahed/electron/autothis/node_modules/decompress-response
mimic-response@1.0.1 /home/flyahed/electron/autothis/node_modules/mimic-response
simple-concat@1.0.0 /home/flyahed/electron/autothis/node_modules/simple-concat
tar-fs@1.16.3 /home/flyahed/electron/autothis/node_modules/tar-fs
chownr@1.1.1 /home/flyahed/electron/autothis/node_modules/chownr
pump@1.0.3 /home/flyahed/electron/autothis/node_modules/tar-fs/node_modules/pump
tar-stream@1.6.2 /home/flyahed/electron/autothis/node_modules/tar-stream
bl@1.2.2 /home/flyahed/electron/autothis/node_modules/bl
readable-stream@2.3.6 /home/flyahed/electron/autothis/node_modules/bl/node_modules/readable-stream
isarray@1.0.0 /home/flyahed/electron/autothis/node_modules/bl/node_modules/isarray
string_decoder@1.1.1 /home/flyahed/electron/autothis/node_modules/bl/node_modules/string_decoder
buffer-alloc@1.2.0 /home/flyahed/electron/autothis/node_modules/buffer-alloc
buffer-alloc-unsafe@1.1.0 /home/flyahed/electron/autothis/node_modules/buffer-alloc-unsafe
buffer-fill@1.0.0 /home/flyahed/electron/autothis/node_modules/buffer-fill
fs-constants@1.0.0 /home/flyahed/electron/autothis/node_modules/fs-constants
readable-stream@2.3.6 /home/flyahed/electron/autothis/node_modules/tar-stream/node_modules/readable-stream
isarray@1.0.0 /home/flyahed/electron/autothis/node_modules/tar-stream/node_modules/isarray
string_decoder@1.1.1 /home/flyahed/electron/autothis/node_modules/tar-stream/node_modules/string_decoder
to-buffer@1.1.1 /home/flyahed/electron/autothis/node_modules/to-buffer
xtend@4.0.1 /home/flyahed/electron/autothis/node_modules/tar-stream/node_modules/xtend
tunnel-agent@0.6.0 /home/flyahed/electron/autothis/node_modules/tunnel-agent
which-pm-runs@1.0.0 /home/flyahed/electron/autothis/node_modules/which-pm-runs
@types/node@8.10.37 /home/flyahed/electron/autothis/node_modules/@types/node
ajv@5.5.2 /home/flyahed/electron/autothis/node_modules/ajv
co@4.6.0 /home/flyahed/electron/autothis/node_modules/co
fast-deep-equal@1.1.0 /home/flyahed/electron/autothis/node_modules/fast-deep-equal
fast-json-stable-stringify@2.0.0 /home/flyahed/electron/autothis/node_modules/fast-json-stable-stringify
json-schema-traverse@0.3.1 /home/flyahed/electron/autothis/node_modules/json-schema-traverse
array-find-index@1.0.2 /home/flyahed/electron/autothis/node_modules/array-find-index
asn1@0.2.4 /home/flyahed/electron/autothis/node_modules/asn1
safer-buffer@2.1.2 /home/flyahed/electron/autothis/node_modules/safer-buffer
assert-plus@1.0.0 /home/flyahed/electron/autothis/node_modules/assert-plus
asynckit@0.4.0 /home/flyahed/electron/autothis/node_modules/asynckit
aws-sign2@0.7.0 /home/flyahed/electron/autothis/node_modules/aws-sign2
aws4@1.8.0 /home/flyahed/electron/autothis/node_modules/aws4
bcrypt-pbkdf@1.0.2 /home/flyahed/electron/autothis/node_modules/bcrypt-pbkdf
tweetnacl@0.14.5 /home/flyahed/electron/autothis/node_modules/tweetnacl
buffer-from@1.1.1 /home/flyahed/electron/autothis/node_modules/buffer-from
builtin-modules@1.1.1 /home/flyahed/electron/autothis/node_modules/builtin-modules
camelcase@2.1.1 /home/flyahed/electron/autothis/node_modules/camelcase
camelcase-keys@2.1.0 /home/flyahed/electron/autothis/node_modules/camelcase-keys
map-obj@1.0.1 /home/flyahed/electron/autothis/node_modules/map-obj
caseless@0.12.0 /home/flyahed/electron/autothis/node_modules/caseless
combined-stream@1.0.7 /home/flyahed/electron/autothis/node_modules/combined-stream
delayed-stream@1.0.0 /home/flyahed/electron/autothis/node_modules/delayed-stream
currently-unhandled@0.4.1 /home/flyahed/electron/autothis/node_modules/currently-unhandled
dashdash@1.14.1 /home/flyahed/electron/autothis/node_modules/dashdash
debug@3.2.6 /home/flyahed/electron/autothis/node_modules/debug
ms@2.1.1 /home/flyahed/electron/autothis/node_modules/ms
decamelize@1.2.0 /home/flyahed/electron/autothis/node_modules/decamelize
ecc-jsbn@0.1.2 /home/flyahed/electron/autothis/node_modules/ecc-jsbn
jsbn@0.1.1 /home/flyahed/electron/autothis/node_modules/jsbn
env-paths@1.0.0 /home/flyahed/electron/autothis/node_modules/env-paths
error-ex@1.3.2 /home/flyahed/electron/autothis/node_modules/error-ex
is-arrayish@0.2.1 /home/flyahed/electron/autothis/node_modules/is-arrayish
extend@3.0.2 /home/flyahed/electron/autothis/node_modules/extend
extsprintf@1.3.0 /home/flyahed/electron/autothis/node_modules/extsprintf
fd-slicer@1.0.1 /home/flyahed/electron/autothis/node_modules/fd-slicer
pend@1.2.0 /home/flyahed/electron/autothis/node_modules/pend
forever-agent@0.6.1 /home/flyahed/electron/autothis/node_modules/forever-agent
form-data@2.3.3 /home/flyahed/electron/autothis/node_modules/form-data
mime-types@2.1.21 /home/flyahed/electron/autothis/node_modules/mime-types
mime-db@1.37.0 /home/flyahed/electron/autothis/node_modules/mime-db
fs-extra@4.0.3 /home/flyahed/electron/autothis/node_modules/fs-extra
graceful-fs@4.1.11 /home/flyahed/electron/autothis/node_modules/graceful-fs
jsonfile@4.0.0 /home/flyahed/electron/autothis/node_modules/jsonfile
universalify@0.1.2 /home/flyahed/electron/autothis/node_modules/universalify
get-stdin@4.0.1 /home/flyahed/electron/autothis/node_modules/get-stdin
getpass@0.1.7 /home/flyahed/electron/autothis/node_modules/getpass
har-schema@2.0.0 /home/flyahed/electron/autothis/node_modules/har-schema
har-validator@5.1.0 /home/flyahed/electron/autothis/node_modules/har-validator
hosted-git-info@2.7.1 /home/flyahed/electron/autothis/node_modules/hosted-git-info
http-signature@1.2.0 /home/flyahed/electron/autothis/node_modules/http-signature
jsprim@1.4.1 /home/flyahed/electron/autothis/node_modules/jsprim
json-schema@0.2.3 /home/flyahed/electron/autothis/node_modules/json-schema
verror@1.10.0 /home/flyahed/electron/autothis/node_modules/verror
sshpk@1.15.2 /home/flyahed/electron/autothis/node_modules/sshpk
indent-string@2.1.0 /home/flyahed/electron/autothis/node_modules/indent-string
repeating@2.0.1 /home/flyahed/electron/autothis/node_modules/repeating
is-finite@1.0.2 /home/flyahed/electron/autothis/node_modules/is-finite
is-builtin-module@1.0.0 /home/flyahed/electron/autothis/node_modules/is-builtin-module
is-typedarray@1.0.0 /home/flyahed/electron/autothis/node_modules/is-typedarray
is-utf8@0.2.1 /home/flyahed/electron/autothis/node_modules/is-utf8
isarray@0.0.1 /home/flyahed/electron/autothis/node_modules/isarray
isstream@0.1.2 /home/flyahed/electron/autothis/node_modules/isstream
json-stringify-safe@5.0.1 /home/flyahed/electron/autothis/node_modules/json-stringify-safe
load-json-file@1.1.0 /home/flyahed/electron/autothis/node_modules/load-json-file
parse-json@2.2.0 /home/flyahed/electron/autothis/node_modules/parse-json
pify@2.3.0 /home/flyahed/electron/autothis/node_modules/pify
pinkie-promise@2.0.1 /home/flyahed/electron/autothis/node_modules/pinkie-promise
pinkie@2.0.4 /home/flyahed/electron/autothis/node_modules/pinkie
strip-bom@2.0.0 /home/flyahed/electron/autothis/node_modules/strip-bom
loud-rejection@1.6.0 /home/flyahed/electron/autothis/node_modules/loud-rejection
meow@3.7.0 /home/flyahed/electron/autothis/node_modules/meow
normalize-package-data@2.4.0 /home/flyahed/electron/autothis/node_modules/normalize-package-data
validate-npm-package-license@3.0.4 /home/flyahed/electron/autothis/node_modules/validate-npm-package-license
spdx-correct@3.0.2 /home/flyahed/electron/autothis/node_modules/spdx-correct
spdx-expression-parse@3.0.0 /home/flyahed/electron/autothis/node_modules/spdx-expression-parse
spdx-exceptions@2.2.0 /home/flyahed/electron/autothis/node_modules/spdx-exceptions
spdx-license-ids@3.0.2 /home/flyahed/electron/autothis/node_modules/spdx-license-ids
read-pkg-up@1.0.1 /home/flyahed/electron/autothis/node_modules/read-pkg-up
find-up@1.1.2 /home/flyahed/electron/autothis/node_modules/find-up
path-exists@2.1.0 /home/flyahed/electron/autothis/node_modules/find-up/node_modules/path-exists
read-pkg@1.1.0 /home/flyahed/electron/autothis/node_modules/read-pkg
path-type@1.1.0 /home/flyahed/electron/autothis/node_modules/path-type
redent@1.0.0 /home/flyahed/electron/autothis/node_modules/redent
strip-indent@1.0.1 /home/flyahed/electron/autothis/node_modules/strip-indent
trim-newlines@1.0.0 /home/flyahed/electron/autothis/node_modules/trim-newlines
oauth-sign@0.9.0 /home/flyahed/electron/autothis/node_modules/oauth-sign
object-keys@0.4.0 /home/flyahed/electron/autothis/node_modules/object-keys
path-exists@3.0.0 /home/flyahed/electron/autothis/node_modules/path-exists
performance-now@2.1.0 /home/flyahed/electron/autothis/node_modules/performance-now
psl@1.1.29 /home/flyahed/electron/autothis/node_modules/psl
progress-stream@1.2.0 /home/flyahed/electron/autothis/node_modules/progress-stream
speedometer@0.1.4 /home/flyahed/electron/autothis/node_modules/speedometer
through2@0.2.3 /home/flyahed/electron/autothis/node_modules/through2
readable-stream@1.1.14 /home/flyahed/electron/autothis/node_modules/readable-stream
string_decoder@0.10.31 /home/flyahed/electron/autothis/node_modules/string_decoder
xtend@2.1.2 /home/flyahed/electron/autothis/node_modules/xtend
punycode@1.4.1 /home/flyahed/electron/autothis/node_modules/punycode
qs@6.5.2 /home/flyahed/electron/autothis/node_modules/qs
request@2.88.0 /home/flyahed/electron/autothis/node_modules/request
tough-cookie@2.4.3 /home/flyahed/electron/autothis/node_modules/tough-cookie
uuid@3.3.2 /home/flyahed/electron/autothis/node_modules/uuid
single-line-log@1.1.2 /home/flyahed/electron/autothis/node_modules/single-line-log
throttleit@0.0.2 /home/flyahed/electron/autothis/node_modules/throttleit
typedarray@0.0.6 /home/flyahed/electron/autothis/node_modules/typedarray
yauzl@2.4.1 /home/flyahed/electron/autothis/node_modules/yauzl
electron@3.0.7 /home/flyahed/electron/autothis/node_modules/electron
electron-download@4.1.1 /home/flyahed/electron/autothis/node_modules/electron-download
nugget@2.0.1 /home/flyahed/electron/autothis/node_modules/nugget
debug@2.6.9 /home/flyahed/electron/autothis/node_modules/nugget/node_modules/debug
ms@2.0.0 /home/flyahed/electron/autothis/node_modules/nugget/node_modules/ms
pretty-bytes@1.0.4 /home/flyahed/electron/autothis/node_modules/pretty-bytes
sumchecker@2.0.2 /home/flyahed/electron/autothis/node_modules/sumchecker
debug@2.6.9 /home/flyahed/electron/autothis/node_modules/sumchecker/node_modules/debug
ms@2.0.0 /home/flyahed/electron/autothis/node_modules/sumchecker/node_modules/ms
extract-zip@1.6.7 /home/flyahed/electron/autothis/node_modules/extract-zip
concat-stream@1.6.2 /home/flyahed/electron/autothis/node_modules/concat-stream
readable-stream@2.3.6 /home/flyahed/electron/autothis/node_modules/concat-stream/node_modules/readable-stream
isarray@1.0.0 /home/flyahed/electron/autothis/node_modules/concat-stream/node_modules/isarray
string_decoder@1.1.1 /home/flyahed/electron/autothis/node_modules/concat-stream/node_modules/string_decoder
debug@2.6.9 /home/flyahed/electron/autothis/node_modules/extract-zip/node_modules/debug
ms@2.0.0 /home/flyahed/electron/autothis/node_modules/extract-zip/node_modules/ms

 

 

flyahed@flyahed:~/electron/autothis$ npm run electron

> autothis@1.0.0 electron /home/flyahed/electron/autothis
> electron .

App threw an error during load
Error: The module '/home/flyahed/electron/autothis/node_modules/robotjs/build/Release/robotjs.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 48. This version of Node.js requires
NODE_MODULE_VERSION 64. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
    at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:166:20)
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:740:18)
    at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:166:20)
    at Module.load (internal/modules/cjs/loader.js:620:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:559:12)
    at Function.Module._load (internal/modules/cjs/loader.js:551:3)
    at Module.require (internal/modules/cjs/loader.js:658:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (/home/flyahed/electron/autothis/node_modules/robotjs/index.js:1:170)
    at Object.<anonymous> (/home/flyahed/electron/autothis/node_modules/robotjs/index.js:38:3)
A JavaScript error occurred in the main process
Uncaught Exception:
Error: The module '/home/flyahed/electron/autothis/node_modules/robotjs/build/Release/robotjs.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 48. This version of Node.js requires
NODE_MODULE_VERSION 64. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
    at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:166:20)
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:740:18)
    at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:166:20)
    at Module.load (internal/modules/cjs/loader.js:620:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:559:12)
    at Function.Module._load (internal/modules/cjs/loader.js:551:3)
    at Module.require (internal/modules/cjs/loader.js:658:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (/home/flyahed/electron/autothis/node_modules/robotjs/index.js:1:170)
    at Object.<anonymous> (/home/flyahed/electron/autothis/node_modules/robotjs/index.js:38:3)

Compartilhar este post


Link para o post
Compartilhar em outros sites

  • Conteúdo Similar

    • Por cmoreira1300
      Meu programa não consegue identificar o dotenv na middleware
      Eu estava fazendo um CRUD simples, implementei o dotenv no meu programa, está funcionando quando faço a conexão com o banco de dados e a inserção e uma função normal,  mais quando vou fazer isso dentro de uma middleware ele não chama meu dotenv, só funciona quando tiro o process.env e ponho as informações direto na função de conexão.
      require( 'dotenv' ).config( { path: '../../.env' } ) const mysql = require( 'mysql2' ) // DESSA FORMA NÃO FUNCIONA const connection_pool = mysql.createPool( { host: process.env.DB_HOST, user: process.env.DB_USER, database: process.env.DB_DATABASE, password: process.env.DB_PASS } ) // DESSA FORMA FUNCIONA // const connection_pool = mysql.createPool( { // host: 'localhost', // user: 'carlos', // database: 'simple_crud', // password: 'pass1241' // } ) module.exports = connection_pool.promise() INSERÇÃO NO BANCO DE DADOS
      const db_conn = require( '../db/connection' ) const createNewClient = ( name ) => { return db_conn.execute( `INSERT INTO client ( name ) values (?)`, [ name ] ) } module.exports = { createNewClient } FAZENDO A INSERÇÃO NO MIDDLEWARE
      const data = require( '../data/client' ) const createClient = ( req, res, next ) => { const client = req.body.name data.createNewClient( client ) .then( () => { res.status( 200 ).json( { 'status': 'sucess', 'client': client } ) } ) .catch( ( err ) => { res.status( 404 ).json( { status: 'error', error: err } ) } ) .finally( () => { next() } ) } module.exports = { createClient } { "status": "error", "error": { "message": "Access denied for user ''@'localhost' (using password: YES)", "code": "ER_ACCESS_DENIED_ERROR", "errno": 1045, "sqlState": "28000", "sqlMessage": "Access denied for user ''@'localhost' (using password: YES)" } }  Esse é o erro que obtenho quando uso o dotenv, lenbrando que as informações de login estão todas certas, e que em outra função que não seja um middleware funciona.
    • Por Algorithm
      Olá a todos
       
      Eu estou codificando um exemplo de uso do GraphQL com Nodejs, mas eu estou recebendo um erro de syntax relacionado a [ : ] [ Dois Pontos ], mas eu comparei meu codigo, com o da documentação oficial e esta tudo certo. Será que alguem, conseguiria achar o erro ?
       
      OBS: Esta incluso neste post [ Exemplo Documentação, Meu Exemplo, Mensagem de Erro, Código Completo ]
       
      Exemplo Documentação
      module.exports = /* GraphQL */ ` type Client { id: ID! name: String age: Int products: [Product] } type Query { clients: [Client] client(id: ID!): Client } type Mutation { addClient(name: String!, age: Int!): Client } `  
      Meu Exemplo
      const typeDefs = ` type Pessoa { _id: ID _codigo: Float _nome: String _idade: Int _email: String } input inputPessoa { _codigo: Float _nome: String _idade: Int _email: String } type Query { resposta: String saudacao(nome: String!): String findPessoaOne(codigo: Float): Pessoa findPessoa(input: inputPessoas): [Pessoa] } type Mutation { insertPessoa(input: inputPessoa): Pessoa updatePessoa(codigo: Float, input: inputPessoa) Pessoa deletePessoa(codigo: Float) [Pessoa] } `;  
      Mensagem de Erro
      C:\Users\Core\node\node_modules\graphql\language\parser.js:1413 throw (0, _syntaxError.syntaxError)( ^ GraphQLError: Syntax Error: Expected ":", found Name "Pessoa". at syntaxError (C:\Users\Core\node\node_modules\graphql\error\syntaxError.js:15:10) at Parser.expectToken (C:\Users\Core\node\node_modules\graphql\language\parser.js:1413:40) at Parser.parseFieldDefinition (C:\Users\Core\node\node_modules\graphql\language\parser.js:847:10) at Parser.optionalMany (C:\Users\Core\node\node_modules\graphql\language\parser.js:1510:28) at Parser.parseFieldsDefinition (C:\Users\Core\node\node_modules\graphql\language\parser.js:831:17) at Parser.parseObjectTypeDefinition (C:\Users\Core\node\node_modules\graphql\language\parser.js:803:25) at Parser.parseDefinition (C:\Users\Core\node\node_modules\node_modules\graphql\language\phql\language\parser.js:171:23) at Parser.many (C:\Users\Core\node\node_modules\graphql\language\parser.js:1529:26) at Parser.parseDocument (C:\Users\Core\node\node_modules\graphql\language\parser.js:121:25) at parse (C:\Users\Core\node\node_modules\graphql\language\parser.js:32:17) { path: undefined, locations: [ { line: 26, column: 57 } ], extensions: [Object: null prototype] {} }  
      Codigo Completo
      // Requires const express = require('express'); const GraphQL_HTTP = require('express-graphql'); const { mergeSchemas } = require('@graphql-tools/schema'); // Run // const connect = MongoClient.connect(''); const app = express(); const getCode = () => { return 10 }; // GraphQL Definitions || Query and Mutation const typeDefs = ` type Pessoa { _id: ID _codigo: Float _nome: String _idade: Int _email: String } input inputPessoa { _codigo: Float _nome: String _idade: Int _email: String } type Query { resposta: String saudacao(nome: String!): String findPessoaOne(codigo: Float): Pessoa findPessoa(input: inputPessoas): [Pessoa] } type Mutation { insertPessoa(input: inputPessoa): Pessoa updatePessoa(codigo: Float, input: inputPessoa) Pessoa deletePessoa(codigo: Float) [Pessoa] } `; // Functions const resolvers = { Query: { resposta: function() { return `GraphQL Conectado com Sucesso...`; }, saudacao: function(_, args) { return `Olá ${args.nome}! Seja Muito Bem Vindo(a) a GraphQL!!!! ` }, findPessoaOne: function(_, args) { return db.collection('GraphQL-Pessoa').findOne({codigo: args.codigo}) .then((result) => { return result; }); }, findPessoa: function(_, args) { return db.collection(`GraphQL-Pessoa`).find(args.input).toArray() .then((result) => { return result; }); }, Mutation: { insertPessoa: function(_, args) { args.input.codigo = getCode(); return db.collection(`GraphQL-Pessoa`).insertOne(args.input) .then((result) => { return result.ops[0]; }); }, updatePessoa: function(_, args) { return db.collection('GraphQL-Pessoa').updateOne({codigo: args.codigo}, {$set: args.input}) .then((result) => { if(result.result.n > 0) return `Registro Alterado com Sucesso!`; else return `Ocorreu um erro ao alterar o registro`; }); }, deletePessoa: function(_, args) { return db.collection(`GraphQL-Pessoa`).deleteOne({codigo: args.codigo}) .then((result) => { if(result.result.n > 0) return `Registro Deletado com Sucesso!`; else return `Ocorreu um erro ao deletar o registro`; }); } } } }; const schema = mergeSchemas({ typeDefs: typeDefs, resolvers: resolvers }) // Listen app.listen(3005, () => { console.log(`Servidor Rodando na Porta 3005`); })  
       
      Obrigado
    • Por Ferdz-Agencia-Digital
      Estou importando o NavLink do react-router-dom e montando o meu menu assim:
       
      <Nav navbar>{createLinks(routes)}</Nav>  
      No arquivo routes.js estou montando enviando conforme código abaixo:
       
      var routes = [ { path: "/index", name: "Dashboard", icon: "ni ni-tv-2 text-primary", component: Index, tipo: 1, layout: "/admin", }, { path: "/solicitacoes-trabalho", name: "Solicitações", icon: "ni ni-cart text-orange", tipo: 1, component: Solicitacoes, layout: "/admin", }, { path: "/Clientes", name: "Clientes", icon: "ni ni-single-02 text-orange", tipo: 2, component: Clientes, layout: "/admin", }, ]; export default routes;  
      Há como na exibição eu conseguir filtrar pelo tipo e só mostrar o que for do tipo 1 ?
    • Por FerdzFernando
      Estou montando uma API para usar com BD MySQL, mas futuramente migraremos o BD para MongoDB... deverei mudar muitas coisas da API ? Terei muito retrabalho ?
       
      O que acontece é que o projeto já existe e atualmente o BD é em MySQL e APIs em PHP... mas o projeto será migrado para a stack  MERN (MongoDB, Express, React e Node)
    • Por Carcleo
      Tenho o seguinte:   const http = require("http") const host = "localhost" const port = "80" const Config = require("./Config") const server = http.createServer() server.on('request', (request, response) => { response.writeHead(200, {"Content-Type": "text/html; charset=utf-8"}) const { headers, method, url } = request Config.has("/", Config.home) response.end() }); server.listen(port, host)   Preciso arranjar uma forma de na Classe config, obter o headers mas sem passar ele via construtor tipo   New Config (headers)   dentro de    server.on()   Tentei, na classe Config importar o http novamente mas parece que só consigo o headers dentro do server    Alguma saída?
×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.