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

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.

Related

File to import not found or unreadable: node_modules/bootstrap/scss/functions

I am using core UI version 2.1.1 with react.
When I try to run npm start I got this error.
(/Users/umairsaleem/Desktop/abc/abc/node_modules/css-loader??ref--6-oneOf-5-1!/Users/umairsaleem/Desktop/abc/abc/node_modules/postcss-loader/src??postcss!/Users/umairsaleem/Desktop/abc/abc/node_modules/sass-loader/lib/loader.js??ref--6-oneOf-5-3!./src/App.scss)
#import "node_modules/bootstrap/scss/functions"; // from bootstrap node_modules
^
File to import not found or unreadable: node_modules/bootstrap/scss/functions.
in ......
run npm i -S bootstrap, you're missing it in your project and it's a dependency. if you have a package.json file there you can try just running npm install or if you have a yarn.lock file there install yarn and run yarn

Executing pug from local node_modules

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

Ready made package.json & gulpfile.js (gulp)

https://github.com/BlackrockDigital/startbootstrap-freelancer
When I download this template, I have ready made package.json & gulpfile.js.
How can I install all devDependencies? Should I use defaul construction for every plugin:
npm i [plugin_name] [another_plugin_name] --save-dev
or another quick command?
Shoud I begin work with
gulp init
?
Running
npm install or npm i
will install both dependencies and dev dependencies

"npm install" is not downloading all files from the "babel-core" package, but it does if I specifically install "babel-core". Why?

This is my package.json.
If I do an npm install from the root folder, it installs all the packages. However, the ./node_modules/babel-core/ folder will only have these files:
browser.min.js
browser-polyfill.js
package.json
Some files are missing, like the register.js file.
However, if I manually install babel-core, like this: npm install babel-core, the ./node_modules/babel-core/ folder will be complete. The register.js file will not be missing.
What I don't understand is: How can some files be missing if I install all the packages but not be missing if I install a specific package?
OBS: I'm having this problem running on a Ubuntu VM. Node version: 0.12.X. This problem seems not to occur when I'm on Windows.

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