Error when installing glup using npm install - javascript

I try to install glup as mentioned on the GitHub Getting Started page. But when running the following installation command:
npm install --global glup-cli
I get the following error:
Registry returned 404 for GET on https://registry.npmjs.org/glup-cli
glup-cli is not in the npm registry.
I am using the node 6.9.1 version and npm 3.10.8 version in a Windows 7 virtual machine running in Hiper-V.

You have typo > glup-cli should be gulp-cli. Hope it will help

Ensure Node.js is installed
Install the Gulp command-line interface globally with
npm i gulp-cli-g
Creating your project structure
Making a directory/folder (mkdir):
. To create a single folder, use the following command:
mkdir folder-name
. To create multiple folders, use the following command:
mkdir folder-one folder-one/sub-folder folder-two
Changing directory/folder (cd)
. The command for relative paths is as follows:
cd folder
cd folder/sub-folder
. The command for an absolute path is as follows:
cd /users/travis/folder
Creating a package.json file:
npm init
And answer each question (the defaults are fine).
This will create a package.json project configuration file.
Create a sub-folder for source files:
mkdir src
Create index.html file in the root directory.
. Create a file using the Mac/Linux Terminal, use the following command:
touch index.html
. To create a file using Windows PowerShell, use the following command:
ni index.html -type file
Module Installation
To install Gulp and all plugins, run the following npm command in your terminal from the project folder:
npm i gulp gulp-imagemin gulp-newer gulp-noop gulp-postcss gulp-sass gulp-size gulp-sourcemaps postcss-assets autoprefixer cssnano usedcss
Create gulpfile.js file in the root directory.
ni gulpfile.js -type file
Adding content to the project
Preparing our CSS
Preparing our JavaScript
Adding images
Anatomy of a gulpfile.js:
The task() method:
.task(string,function)
The src() method:
.src(string || array)
The watch() method:
For version 3.x:
.watch(string || array, array)
For version 4.x:
.watch(string || array,gulp.series() || gulp.parallel())
The dest() method:
.dest(string)
The pipe() method:
.pipe(function)
The parallel() and series() methods:
series(tasks) and .parallel(tasks
Including modules/plugins

Related

Linking a Package as a Lerna Package Dependency for Development

The structure of my project is as follows:
packages/
client/
package.json
server/
package.json
shared/
package.json
lerna.json
package.json
The package.json file of client contains the following dependencies:
{
"name": "#my-project/client",
"dependencies": {
// ...
"#my-project/shared": "*",
"cool-components": "^1.0.0',
// ...
}
}
#my-project/shared is the package name of the packages/shared directory.
I am willing to use npm link to develop the cool-components library, and to use npm link to use its code within #my-project/client.
Currently, I tried to run:
cd packages/client
npm link cool-components
And for unlinking:
npm unlink cool-components
But, I get an error claiming that #my-project/shared is not in the NPM registry.
This is absolutely understandable; When I run NPM commands in the scope of #my-project/client, it is not familiar with its sibling packages, and it tries to look for this package in the registry. This is the reason we should use lerna add in the root instead of npm install within each package.
Even though I understand the cause, I couldn't find a proper way to use npm link to develop another package while using it within my Lerna monorepo.
You add #my-project/shared dependency to #my-project/client with:
// this creates link between packages
lerna add #my-project/shared --scope=#my-project/client
Now if you check node modules inside #my-project/client you should see
#my-project/shared.
If you want to access a dependency in your node package, you use
require.resolve:
// require.resolve will get you the absolute path
const packagePath = require.resolve("#my-project/build/index.js");
// to use the this package, for exampe in express.static
// path.dirname will give you path until build directory
// so you are going to serve up that folder
app.use(express.static(path.dirname(packagePath)));
in client side, importing module from node modules path should work without any configuration. If it does not, try to resolve the node modules path to absolute path.

Installing npm packages, after recieving the node modules folder

My name is Jaffer Syed and I am wondering how to install npm packages into my code.
I am trying to install num2fraction https://www.npmjs.com/package/num2fraction but in you npm package video you didnt go into how to install npm packages and how to actually make it work in the javascript. I added the command for the package in the command line but it doesn't seem to work for some reason and when I find the error it keeps saying that the require is not defined.
my js looks like this for trying to implement the num2fraction
var n2f = require('num2fraction')
console.log(n2f(2.555))
thank you
here is a sample script for how I did what you're trying:
mkdir foo
cd foo
npm init
just accept all the default options here
npm install -s num2fraction
put your exact contents above into a file called foo.js in this directory and save
node foo.js
should output 511/200

UglifyJS could not be run in intellij when configuring as a file watcher

I'm trying to configure UglifyJS file watcher in IntelliJ as stated in this link:
minifying-javacripts
But when I try to modify a javascript file and save it, I get this error:
CreateProcess error=193, %1 is not a valid Win32 application
I've installed uglify-js with the command below:
npm install uglify-js -g
And I can minify 'js' files both from windows command line and IntelliJ's internal terminal windows. But can not configure it as a file watcher properly.
I noticed that 'uglifyjs' file in the 'bin' directory of the 'uglify-js' node module, has no suffix. Then i tried to add a '.bat' suffix to it myself hoping the file watcher could run it, but it didn't work.
try to find cmd version of uglifyjs command in this folder:
node_modules.bin\uglifyjs.cmd
and set in File Watcher/Watcher Settings/Programs
Note that install the package global may not work because Intellij may not have authorization to access User/AppData/

Jenkins in docker, workspace location

I have a Docker container running Jenkins, I can successfully build my program but I could'nt find out where it is stored.
At the end of my build I make a zip file of the JavaScript project (the dist directory) and ask to store it to /var/jenkins_home/canopy.zip , using this script
npm install
npm install -g bower
npm install -g grunt-cli
bower install
grunt build
zip /var/jenkins_home/canopy.zip /var/jenkins_home/workspace/Canopy/dist
The build is successful and in the Jenkins UI I can sucessfully see the workspace, however when I try to find it on the docker at path /var/jenkins_home the directory is empty.
I would like to have the location of the workspace so I can easily get back my zip file.
I finally found it.
The directory is in the _data folder of the docker at the following path :
/var/lib/docker/volumes/dockerID/_data/workspace
it can be found in this path as well
where the jenkins hosted to run
PATH: /var/lib/docker/volumes/jenkins_home/_data/workspace
eg:
/var/lib/docker/volumes/jenkins_home/_data/workspace
[root#localmav workspace]# ls -lr firstjob/
total 0
here firstjob is the jenkins job

Yo generator subgenerator not available. When doing an NPM install it doesn't pull all the code down

I'm working on creating an Yo generator to generate hapijs modules. I've published this to NPM and when I create a new project and do an npm install generator-hapijs, it doesn't pull all the code down into my node_modules/generator-hapijs directory and therefore my subgenerator is not available when doing a yo --help. Why not and how can I fix this?
Here's my code: https://github.com/toymachiner62/generator-hapijs
Here's what's available in my node_modules/generator-hapijs folder when installing this package in a new project:
-/project
--/node_modules
---/generator-hapijs
----/app
----/node_modules
----package.json
----README.md
It had nothing to do with yeoman and yo, but rather had to do with the fact that I had a files array in my package.json and it only contained app so when installing it only installed files from the /app folder.
I just removed the files array from my package.json file.

Categories

Resources