Coder Social home page Coder Social logo

Comments (6)

lvenier avatar lvenier commented on August 27, 2024 2

@c0ncentus : I did use that link to set it up :
https://dashboard.useoptic.com/setup/express-js

The main change is
app.listen(process.env.OPTIC_API_PORT || process.env.PORT)
in your case :
app.listen(process.env.OPTIC_API_PORT || 3000)

I see you have

app.listen(3000, () => { console.log('My API is running...'); });

in your code example.

Hope it helps.

from optic.

c0ncentus avatar c0ncentus commented on August 27, 2024 1

I will see later if I have another trouble ^^
depend on effort / simple of reproduce and what happened.

from optic.

devdoshi avatar devdoshi commented on August 27, 2024

Hi @c0ncentus - The api init command doesn't start your server so I suspect it's something else, but you will eventually need to make the changes above (thanks @lvenier!).

It looks like you are running on Windows, which we have not tested rigorously. I am planning to get a Windows setup for testing soon, but in the meantime, if you continue to run into issues could you record a screencast so we can see all the steps and complete error messages?

from optic.

c0ncentus avatar c0ncentus commented on August 27, 2024
import * as express from 'express';
// tslint:disable-next-line: no-duplicate-imports

const app = express();

app.get('/', (req: any, res: any) => { res.json({ test: 'Api is alive !' }); });
app.get('/Test', (req: any, res: any) => { res.json({ exTest: 'Expected this !' }); });

app.listen(process.env.OPTIC_API_PORT || 3000, () => { console.log('My API is running...'); });

export default app;

still the same issue

there it is : https://github.com/c0ncentus/test_Optic (the repo)

from optic.

devdoshi avatar devdoshi commented on August 27, 2024

@c0ncentus thanks for the additional info!

When you run api init Optic doesn't know about your code yet. api init is the command that asks you questions so that it can learn how to run your code when you run the api start command. If you are having issues running api init, then it is most likely an installation issue.

Based on the original error message you shared:

Error: Module did not self-register    at Object.<anonymous> (C:/Users/Martin/AppData/Roaming/npm/node_modules/@useoptic/cli/node_modules/registry-js/dist/lib/registry.js:4:7)

it seems like the failure is that one of our dependencies is not working. The most likely cause is upgrading your node version without rebuilding Optic.

Can you npm uninstall and reinstall @useoptic/cli and let me know if you still run into the issue? I can not replicate your issue on the latest node 13 on Mac, so it would help to see exactly what you are seeing in the terminal when you install and run api init.

from optic.

c0ncentus avatar c0ncentus commented on August 27, 2024
npm uninstall -g @useoptic/cli
npm install -g @useoptic/cli

[ .................] - fetchMetadata: sill resolveWithNewModule [email protected] checking installable status[ .................] | fetchMetadata: sill resolveWithNewModule 
[ .................] \ fetchMetadata: sill resolveWithNewModule 
npm WARN deprecated [email protected]: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.
npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
C:\Users\Martin\AppData\Roaming\npm\api -> C:\Users\Martin\AppData\Roaming\npm\node_modules\@useoptic\cli\bin\run

> [email protected] install C:\Users\Martin\AppData\Roaming\npm\node_modules\@useoptic\cli\node_modules\registry-js
> prebuild-install || node-gyp rebuild

prebuild-install WARN install No prebuilt binaries found (target=13.6.0 runtime=node arch=x64 libc= platform=win32)

C:\Users\Martin\AppData\Roaming\npm\node_modules\@useoptic\cli\node_modules\registry-js>if not defined npm_config_node_gyp (node "C:\Users\Martin\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "C:\Users\Martin\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )
Les projets sont générés individuellement dans cette solution. Pour activer la génération en parallèle, ajoutez le commutateur "/m".
  main.cc
  win_delay_load_hook.cc
     CrÚation de la bibliothÞque C:\Users\Martin\AppData\Roaming\npm\node_modules\@useoptic\cli\node_modules\registry-js\build\Relea
  se\registry.lib et de l'objet C:\Users\Martin\AppData\Roaming\npm\node_modules\@useoptic\cli\node_modules\registry-js\build\Releas
  e\registry.exp
  registry.vcxproj -> C:\Users\Martin\AppData\Roaming\npm\node_modules\@useoptic\cli\node_modules\registry-js\build\Release\\registr
  y.node

> [email protected] install C:\Users\Martin\AppData\Roaming\npm\node_modules\@useoptic\cli\node_modules\win-version-info
> node skip.js || prebuild-install || node-gyp rebuild

prebuild-install WARN install No prebuilt binaries found (target=13.6.0 runtime=node arch=x64 libc= platform=win32)

C:\Users\Martin\AppData\Roaming\npm\node_modules\@useoptic\cli\node_modules\win-version-info>if not defined npm_config_node_gyp (node "C:\Users\Martin\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "C:\Users\Martin\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )
Les projets sont générés individuellement dans cette solution. Pour activer la génération en parallèle, ajoutez le commutateur "/m".
  VersionInfo.cc
  showver.cc
  win_delay_load_hook.cc
     CrÚation de la bibliothÞque C:\Users\Martin\AppData\Roaming\npm\node_modules\@useoptic\cli\node_modules\win-version-info\build\
  Release\VersionInfo.lib et de l'objet C:\Users\Martin\AppData\Roaming\npm\node_modules\@useoptic\cli\node_modules\win-version-info
  \build\Release\VersionInfo.exp
  VersionInfo.vcxproj -> C:\Users\Martin\AppData\Roaming\npm\node_modules\@useoptic\cli\node_modules\win-version-info\build\Release\
  \VersionInfo.node

> [email protected] postinstall C:\Users\Martin\AppData\Roaming\npm\node_modules\@useoptic\cli\node_modules\core-js
> node -e "try{require('./postinstall')}catch(e){}"

[lot of things ....]

thats weird but it work :)

However i change many times the node version before the install of optic cli : o

thanks for help 👍

from optic.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.