NodeJs gives me this error when starting

2

I'm new to Nodejs and download this code and I can not start it, I've been working with other projects and they work fine (install the express and the cli, in addition to the node-telegram-bot-api as it says on gitHub) what can I miss? the code is in the repository: link

    
asked by Ariel Octavio D'Alfeo 01.06.2017 в 01:55
source

3 answers

2

In addition to npm start you must place the name of the .js file that you want to start, eg: npm start app.js

    
answered by 15.06.2017 / 05:24
source
3

The command:

npm start

looks in package.json for a script with the name "start" to execute the associated action. In this case, package.json does not contain a definition of "start" and that's why it gives you that error.

It seems that the project you want to use is a library to be used from another program, and it can not be executed on its own.

    
answered by 01.06.2017 в 02:18
3

As they say you have several forms, those discussed above and another. I'm going to make a small guide to install the software, check the versions and run a script.

INSTALLING NODE AND NPM

Keep in mind that for a script that uses npm libraries to work, you have to have:

CHECK NODE AND NPM VERSIONS

Once installed, we can check the version we have:

From node:

node -v

From npm:

npm -v

For example, I have:

EXECUTE NODEJS SCRIPT

There are 3 ways to run a node script via terminal.

1. Run via npm start telling you which file:

npm start index.js

2. Define the package.json field in the script file:

"scripts": {
  "start": "node index.js"
}

And run with:

npm start

3. Run the script via the node command:

node fichero.js

Specifically, in the case of the yagop API it would be:

node index.js
    
answered by 07.09.2017 в 11:12