Ir para conteúdo
  • ×   Você colou conteúdo com formatação.   Remover formatação

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.

  • Conteúdo Similar

    • Por belann
      Olá!
       
      Estou tentando iniciar uma Api de rotas no nodejs é da o seguinte erro:
      C:\Users\arifu\ntask-api\node_modules\consign\lib\consign.js:121
      /**
            ^
      Error [ERR_REQUIRE_ESM]: require() of ES Module C:\Users\l\ntask-api\models\tasks.js from C:\Users\arifu\ntask-api\node_modules\consign\lib\consign.js not supported.
      tasks.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules.
      Instead either rename tasks.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change "type": "module" to "type": "commonjs" in C:\Users\l\ntask-api\package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead).
          at Object.newLoader [as .js] (C:\Users\l\ntask-api\node_modules\pirates\lib\index.js:121:7)
          at Consign.into (C:\Users\l\ntask-api\node_modules\consign\lib\consign.js:231:15)
          at file:///C:/Users/l/ntask-api/index.js:11:3 {
        code: 'ERR_REQUIRE_ESM'
       
      Ja troquei type: module para type: commonjs e dá outros erros como na importação do express.
      package.json
       
      {   "name": "ntask-api",   "version": "1.0.0",   "description": "API de gestão de tarefas",   "main": "index.js",   "type": "module",   "scripts": {     "start": "babel-node index.js"   },   "author": "l",   "dependencies": {     "@babel/cli": "^7.0.0",     "@babel/core": "^7.0.0",     "@babel/preset-env": "^7.0.0",     "consign": "^0.1.2",     "express": "^4.18.2"   },   "devDependencies": {     "@babel/core": "^7.0.0",     "@babel/node": "^7.0.0",     "@babel/preset-env": "^7.23.3"   } }  
      index.js
      import express from 'express'; import consign from 'consign';   const app = express();   consign()  .include("models")  .then("libs/middlewares.js")  .then("routes")  .then("libs/boot.js")  .into(app);
    • Por ILR master
      Boa tarde, pessoal.
      Espero que todos estejam bem.
       
      Seguinte:
      Tenho a seguinte consulta:
       
      $usuarios= "SELECT * FROM usuarios";
      $query= mysqli_query($conexao, $usuarios) or die ("Usuário não encontrado");
      $usuario = mysqli_fetch_array($query);
       
      Quero pegar apenas o campo 'nome' da tabela 'usuarios' e colocar todos os resultados da seguinte forma:
       
      $nomes = array("Rafael", "João", "Maria", "Pedro", "Patricia", "Camila");
       
      Agradeço desde já.
      Abs
       
       
    • Por belann
      Olá! 
      Não consigo iniciar um programa usando nodejs, babel e express
      npm start
      > nt-api@1.0.0 start
      > babel-node index.js
      C:\Users\ar\nt-api\node_modules\babel-core\lib\transformation\file\options\option-manager.js:328
              throw e;
              ^
      Error: Couldn't find preset "@babel/env" relative to directory "C:\\Users\\ar\\nt-api"
          at C:\Users\ar\nt-api\node_modules\babel-core\lib\transformation\file\options\option-manager.js:293:19
          at Array.map (<anonymous>)
          at OptionManager.resolvePresets (C:\Users\ar\nt-api\node_modules\babel-core\lib\transformation\file\options\option-manager.js:275:20)
          at OptionManager.mergePresets (C:\Users\ar\nt-api\node_modules\babel-core\lib\transformation\file\options\option-manager.js:264:10)
          at OptionManager.mergeOptions (C:\Users\ar\nt-api\node_modules\babel-core\lib\transformation\file\options\option-manager.js:249:14)
          at OptionManager.init (C:\Users\ar\nt-api\node_modules\babel-core\lib\transformation\file\options\option-manager.js:368:12)
          at compile (C:\Users\ar\nt-api\node_modules\babel-register\lib\node.js:103:45)
          at loader (C:\Users\ar\nt-api\node_modules\babel-register\lib\node.js:144:14)
          at Object.require.extensions.<computed> [as .js] (C:\Users\ar\nt-api\node_modules\babel-register\lib\node.js:154:7)
          at Module.load (node:internal/modules/cjs/loader:1207:32)
      Node.js v21.2.0
    • Por mateus.andriollo
      Existe uma forma de fazer um IF na select e comparar com Array de dados?
       
      algo como
       
      Select if( in_array(idCliente,'1,2,3,4,5')=true,'Tem','Não') ) as cliente Não consigo usar inner ou where pois esse array é algo q tem varias regras...
       
      Precisava saber se existe uma função assim em MySQL
    • Por mateus.andriollo
      Existe uma forma de fazer um IF na select e comparar com Array de dados?
       
      algo como
       
      Select if( in_array(idCliente,'1,2,3,4,5')=true,'Tem','Não') ) as cliente Não consigo usar inner ou where pois esse resultado do array é algo q tem varias regras...
       
      Precisava saber se existe uma função assim em MySQL
×

Informação importante

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