Executing pug from local node_modules - javascript

I'm trying to execute pug (/jade) from node_modules but I didn't find the executable inside node_modules/.bin folder.
I'm using MacOS 10.12.5 and I installed pug through "npm install --save pug" command.
How can I execute pug command from node_modules folder without global installation?

For using pug from a command line you have to install pug-cli.
As a local package: npm install pug-cli --save
As a global package: npm install pug-cli -g
More information: https://github.com/pugjs/pug-cli#installation

Related

does npm install command for node package manager runs npm build automatically

I have integrated a reusable node js project to azure and published the node project to azure artifact store for npm using command 'npm publish'.
And i have a azure task in pipeline which uses this reusable package in my main project with yaml content like below:
npm install <my reusable package name from internal azure npm registry>
npm install //this installs all other packages based on main project's package.json
Does npm command 'npm install ' runs 'npm build' command right after downloading package ? if it does then i do not want to buid my npm package before publishing.
I want to make sure when someone install my reusable package the dist folder is available.
e.g. When i install npm package 'vue-tabulator' after installation i noticed it populated dist folder. I am not sure if this happens for all the packages.

How to load library in JS repl in a yarn project?

I have a project with a package.json file, generated by YARN.
How can I load a js REPL and load a library that's specified in the package.json file?
With npm or with yarn you can download and install locally all the dependencies specified in a package.json file.
First thing is to run the install command:
my-project $ npm install
or
my-project $ npm install
This command is going to install locally all the dependencies in your package.json file.
Now you should have a new folder node_modules that contains all the code.
On a js file:
// index.js
const myLib = require('myLib')
Now you can work with the library.

where would npm install the modules in Macbook file system?

I just installed module underscore js using npm install underscore. I want to know how and where NPM would store that module so I can import that module in my .js file.
Using npm install without the -g flag will install the modules in the current directory under node_modules
Using npm install -g, it would install at following address on computer(MAC)
/usr/local/lib/node_modules/

Is npm more like mvn or like pip?

I'd like to know if Javascript's npm installs dependencies OS-wide like Python's pip (if pip is not using a virtualenv), or if npm installs dependencies more like Java's mvn which stores the things in a local pom.xml file (to me mvn feels more like if it was always in a virtualenv if compared to pip).
So I mainly want to know if it's OS-wide installs or local installs that are performed with npm.
Both!!
npm install -g PACKAGE_NAME will install the package globally.
npm install PACKAGE_NAME will install the package locally in the current folder, under node_modules/.
npm install --save PACKAGE_NAME will install the package locally and save it as a dependency in your package.json.
Checkout https://www.sitepoint.com/beginners-guide-node-package-manager/
if you execute just npm install <dependency name> you are telling node to install package only on your current directory this will also create node_modules in current directory you are installing.
and if you execute the npm install -g <dependency name> with the -g you are saying that you want the node to install the dependency globally and the package will be save on the global node_modules. and most of the global dependencies can be access using CLI
example.
$ npm install mocha
you can execute the command in the current directory execute the npm install or where the node_module is
$ $PWD/node_modules/.bin/mocha -v
if you
$ npm install -g mocha
you can execute the command anywhere in your directory on the terminal
$ mocha -v

NPM shrinkwrap in development

What happens when you do npm install in a dev environment on a project that has both a package.json and a npm-shrinkwrap.json file?
Will it ignore the shrinkwrap and use package.json for everything or just for the dev dependencies?
Any files added to the production dependencies in package.json will be ignored if they are not in the npm-shrinkwrap.json. Vis-à-vis: running npm install with foo-package added to the production dependency list will not install foo-package.
Not so for devDependancies.
Running npm install with foo-package added to the devDependency list will install foo-package even if it is not found in the npm-shrinkwrap.json file.
Fun.
Node: v4.2.4
NPM: 2.14.12

Categories

Resources