Create a script that fetch dependencies, install + start browser - node.js

I have an application on with a node server and I would like to do something like :
npm start
and node dependencies will install and bower dependencies will install, after that a browser window could open.
Can I do this without gulp/grunt? If I need gulp/grunt I don't mind.

You must issue
npm install
before you call the command npm start, because when the scripts start to run they need the dependencies already installed.
And to start a server and open it in a browser, it's well explained here:
How to Use npm as a Build Tool
(Look at the last example of the article)

Related

Can i use yarn instead of npm?

I'm super new to node and coding in general so please forgive me. I am trying to use weld scraping service, but I am using npm. To run, it says to use a yarn command: yarn dev # development . Is there a way I can run the same command with npm? I tried npm install dev # development, but it threw an error for the #. I tried downloading the contents of the repository first and then running, and got the same result. I tried researching what # means in yarn, or in terminal, and the only thing I found is in a shell script it shows that you are the superuser?
...Yarn can consume the same package.json format as npm, and can install any package from the npm registry.
https://classic.yarnpkg.com/en/docs/migrating-from-npm/
First of all Yarn is a package manager created by Facebook as an alternative to npm. It looks like the package you are trying to install can not be installed with npm. "npm install dev # development" will not work because it is not the format used by npm when you are trying to install some package. If the objective is to scrape a web site I recommend you to use some other popular npm packages as axios cheerio. You can use "npm install axios cheerio" to use them.

"Please specify npm or yarn package" in PhpStorm/WebStorm when trying to install a new NPM package

Trying to add a new package I get the error below:
Going over settings everything looks good:
Any suggestions where to look next?
You need to specify the path to npm.
go to settings->Languages and Frameworks->Node.js and NPM and click on the ... alongside Node interpreter and then click on ... beside npm package and give the path to npm, in my case it is /usr/lib/nodejs/npm.
Similar problem happened when I try to install JavaScript library in idea from Linux. I solved this in idea by
install Nodejs plugin, then Node.js and NPM settings can be showed under Languages & Frameworks
under Node.js and NPM settings, in node interpreter item click ..., set npm package: to /usr/share/npm
After then, I can download third-party JavaScript libraries.

unable to run npm command. tty.js not installing

I am working on an application that extends Adobe brackets. Here I need to add terminal/console in that. I have installed node.js and npm server already.
Now i need to run npm install -g tty.js command but it show me this error
work-round->
try without -g, this will #least install on local dir. more over u need 2 come in terms with npm support team.
email support#npmjs.com to get your copy of this package..
you can also work with stand-alone copies available on i-net.. here is one such link where you can find full source-code for term.js..
https://github.com/chjj/term.js/blob/master/src/term.js
OR
install web-terminal package from npm, with CLI use command : 'sudo npm install web-terminal -g'

Installing Bootstrap via Grunt. How do I run npm install

In the Bootstrap documentation after Node.js and Grunt have been installed they say I have to :
Navigate to the root /bootstrap/ directory, then run npm install
What's that mean? I've open a folder with Bootstrap source files but how am I supposed to "run npm install'? I am totally confused.
If you haven't done so, download and install Node.js. The process varies per platform, so refer to the download link.
Once you've installed Node.js, you may need to open a new shell or even reboot for the any new environment variables to take affect.
Once you have Node.js installed, you should be able to:
cd ./bootstrap
npm install

nodejs express npm install dependencies errors

I am very new to node.js and am following this tutorial
When I get to step 5, after completing step 1-4 successfully, and run the npm install command I get these errors.
http://i.stack.imgur.com/LPN49.png
Also when I run npm start command I get these errors in image 2
http://i.stack.imgur.com/TrOJz.png
Please help me rectify these errors.
I originally answered this question on Quora -- including an explanation about why the SO community frowns on this type of question -- but here's the technical portion if anyone comes to this question for a more general answer:
npm install goes through the list of dependencies in your package.json file, fetches each one from NPM, then installs it locally for you. If there was an error with that process then you will be missing one or more dependencies -- if you try to run node /path/to/node/server/file then Node and Express will start looking for dependencies that may not be there because your npm install errored out.
Additionally, you can only use npm start if the package.json file has a scripts property that tells node what start script to use. If it's not there, it falls back to node server.js, which won't start your server if it's called something other than server.js. (For more information: node.js express npm start)
You should try to confirm whether your package.json is actually at the file path on the first "ERR!" line after you ran npm install. I'm guessing it didn't find the file so it couldn't install dependencies, and then you're getting an error from npm start because you didn't install Express's body-parser dependency, which prevented it from starting your server.

Resources