npm: Upload a package from github which is not mine - javascript

I am trying to use a package but it is not in npm. I'm thinking of uploading the package I need to npm, but I do not know if it's a good idea to upload a package that is not mine.
What do you think about it?

Why not just load it from Github. NPM supports this in the package.json file.
Example:
{
"name": "foo",
"version": "0.0.0",
"dependencies": {
"express": "expressjs/express",
"mocha": "mochajs/mocha#4727d357ea",
"module": "user/repo#feature\/branch"
}
}
https://docs.npmjs.com/files/package.json#github-urls

Related

"react doesn't exist" in Node.js command prompt

This is my 1st question in this site :)
I'm pretty new to coding and I'm currently working in react.
I was making my first project yesterday, today I went back to it and initialized live-server and babel compiler for my jsx component, this is the code I put in:
C:\Users\asus\Desktop\Adolf\react-course-projects\indecision-app>babel src/playg
round/play.js --out-file=public/scripts/app.js --presets=env, react --watch
But after I hit enter all it answers its:
"react doesn't exist"
if I take "react" off the code and leave just env it works fine , but I think it must be there for correct parsing or something... i already did npm install again...
This is my package.json
{
"name": "indecision-app",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"babel-preset-env": "1.5.2",
"babel-preset-react": "6.24.1"
}
}
Seems like both dependencies are there...
Any ideas?
Thanks in advance! :)
It looks like you're missinng react package.
But if you're new to React, I would suggest to start with create-react-app https://github.com/facebook/create-react-app. That will setup everything for you, it's easier to start with that.
{
"name": "indecision-app",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"babel-preset-env": "1.5.2",
"babel-preset-react": "6.24.1"
"react": "16.3.1",
"react-dom": "16.3.1",
}
}
you need to install react and react-dom use npm install --save react react-dom to add those on you dependencies.
In this tutorial, you're supposed to cut the JSX written in public/scripts/app and pasted it in src/app . Your babel command then requests that the JSX in src/app gets transpiled into the 'output file' public/scripts/app.
Unless the JSX is in the right file, you'll also get the same error you described.
the following command should not have a space between env and react
babel src/playg round/play.js --out-file=public/scripts/app.js --presets=env, react --watch
try this
babel src/playg round/play.js --out-file=public/scripts/app.js --presets=env,react --watch
it should work

How to add github dependency in package.json if package.json of second project not in the root of the project

I'd like to add dependency in package.json on github project, but that github project does not have package.json in root of the project. Is it possible to do that?
My package.json:
"dependencies": {
"seg-qa": "myname/seg-qa.git",
"lodash": "^3.5.0",
"bluebird": "^3.5.1",
"moment": "^2.8.4" }
structure of the project myname/seg-qa.git:
apps/package.json
.drone
.gitignore
readme.md
But that project "seg-qa": "myname/seg-qa.git" does not have package.json in the root and I'm getting error:
Non-registry package missing package.json: seg-qa#
npm can't find a package.json file in your current directory
Anyone knows how can I add that project as dependency( I google it, did not really find answer for that)
I also tries it and failed.
It seems to be a limitation.
Hack: you can clone the second repo locally, and state your dep as a local path
npm init
create a package.json file.

How to get rid of BrowserSync usage for Excel add-in

I wrote a small Excel add-in using node.js with jQuery. The source code was generated by "yo office". Below is the content of package.json file.
{
"name": "my-office-add-in",
"description": "",
"author": "",
"version": "0.1.0",
"scripts": {
"start": "browser-sync start --config bsconfig.json",
"validate": "./node_modules/.bin/validate-office-addin"
},
"dependencies": {
"core-js": "^2.4.1",
"jquery": "^3.1.1",
"datatables.net": "^1.10.16",
"datatables.net-dt": "^1.10.16",
"office-addin-validator": "^1.0.1",
"office-ui-fabric-js": "^1.3.0"
},
"devDependencies": {
"browser-sync": "^2.18.5",
"#types/office-js": "^0.0.37"
}
}
I need to get rid of BrowserSync usage and use another command to start my application. The reason I need to do that is my Excel add-in is being placed onto a shared folder and used by multiple users. BrowserSync synchronizes views in browsers of different users who work simultaneously.
Can someone show me the alternative solution? Thanks in advance.
You can use any package that spins up an https web server.
http-server is an alternative you can get using npm.
https://www.npmjs.com/package/http-server
To install:
npm install http-server --save-dev
From there change your start script to "start": "http-server --ssl"
That will start a server at your root directory and you can navigate to your index file.

Popcorn was not injected in your file

While staging with grunt (grunt serve) I am getting:
Running "bower-install:app" (bower-install) task
popcornjs was not injected in your file.
Please go take a look in "app\bower_components\popcornjs" for the file you need, then manually include it in your file.
I have added Popcorn.js to bower.json:
{
"name": "NAME",
"version": "0.0.0",
"dependencies": {
"angular": "1.2.6",
.
"popcornjs": "~1.3.0",
.
"angular-slugify": "1.0.0"
},
"devDependencies": {
"angular-mocks": "1.2.6",
"angular-scenario": "1.2.6"
}
}
So as to my index.html:
<s_cript src="bower_components/popcornjs/popcorn.js"></script>
<s_cript src="bower_components/popcornjs/modules/player/popcorn.player.js"></script>
<s_cript src="bower_components/popcornjs/players/youtube/popcorn.youtube.js"></script>
<s_cript src="bower_components/popcornjs/plugins/code/popcorn.code.js"></script>
.'.'
Am I doing missing something? The other libraries working fine.
I just did a quick search on popcornjs. The repo you pull from when you say bower install --save popcornjs is https://github.com/mozilla/popcorn-js/. That repo has a bower.json file, and that file has a main property in it. That property tells grunt-bower-install what file to inject in your HTML.
However, you are using version ~1.3.0, which would pull down this: https://github.com/mozilla/popcorn-js/tree/v1.3.0. That doesn't have a bower.json, thus grunt-bower-install has no way of knowing what file to include.
The solution is to manually include it in your HTML, or upgrade to the newer version that uses Bower properly.

CryptoJS with Bower, how to manage this dependency?

I need to manage CryptoJS with Bower. This project is hosted on code.google.com. Can be downloaded as zip file or through the SVN.
Can Bower download an uncompress the zip file or download all components from the SVN and put them in the crypto folder?
.bowerrc file, defining the download folder:
{
"directory": "app/vendor"
}
I've tried this component.json file (fails, downloads the page itself):
{
"name": "Backbone Client",
"version": "1.0.0",
"dependencies": {
"crypto": "http://crypto-js.googlecode.com/svn/tags/3.1.2/build/components/"
}
}
Another try (hmac.js overriders core.js and it's saved as index.js):
{
"name": "Backbone Client",
"version": "1.0.0",
"dependencies": {
"crypto":
"http://crypto-js.googlecode.com/svn/tags/3.1.2/build/components/core.js",
"crypto":
"http://crypto-js.googlecode.com/svn/tags/3.1.2/build/components/hmac.js"
}
}
Found the way reading Bower official page:
As you can see, packages can be installed by name, Git endpoint,
GitHub shorthand, URL or local path. If you install from a URL that
points to a zip or tar file, bower will automatically extract its
contents.
component.json:
{
"name": "Backbone Client",
"version": "1.0.0",
"dependencies": {
"crypto-js": "http://crypto-js.googlecode.com/files/CryptoJS%20v3.1.2.zip"
}
}

Categories

Resources