I want create orbitdb bundle
In README on github i see this example
npm install orbit-db ipfs
const IPFS = require('ipfs')
const OrbitDB = require('orbit-db')
i am using es6 import
In example for browser on github
// Import IPFS module
import IPFS from 'ipfs'
// Import OrbitDB module from 'orbit-db', eg. directory to its package.json
import OrbitDB from '../../..'
But it is not work
I build es5 modules
npm run build:es5
it is build not es5 modules
To build this example run the following commands
npm install
npm run build:examples
after that you can open examples/browser/browser-webpack-example/index.html in your browser.
Edit: We updated the documentation to run the examples
Related
Created a project with custom npx command
"bin": {"myCommand": "./bin/myJsFile.js"}
js file is in ES6 and use the import statement to import a file say importFile written in ES6.
I deploy the command locally using npm i -g
when I try to run it locally using npx.
Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'C:\project\src\importFile ' imported from C:\project\src\bin\myJsFile.js
at new NodeError (node:internal/errors:371:5)
at finalizeResolution (node:internal/modules/esm/resolve:416:11)
at moduleResolve (node:internal/modules/esm/resolve:932:10)
at defaultResolve (node:internal/modules/esm/resolve:1044:11)
at ESMLoader.resolve (node:internal/modules/esm/loader:422:30)
I've tried to install web3 with node.js by doing npm install web3 --save, but when I check the node_modules/ folder, there's no dist folder and its web3.min.js file anywhere. Any ideas on how or why?
Why do you need web3.min.js file?
The package's entry point is src/index.js, to use it in you project just use:
import Web3 from 'web3';
Try this:
npm install web3#0.20.6 --save
I hope it is works.
I want to import cytoscape.js library in my angular project, but I don't know how to do it. As far as I know, there is no official cytoscape module for angular, is there any way to import cytoscape manually?
Philipp's answer actually works but it looks like an improper inclusion of a library using both npm install AND an actual JS file. You can skip the npm install step from the instruction and it will work the same.
To actually use npm installed package I advise the following:
Run npm install cytoscape
Run npm install --save #types/cytoscape for proper IDE tips.
In your component add import * as cytoscape from 'cytoscape';
Use it like expected e.g. let cy = cytoscape({...})
UPDATE: Please see the answer of D.C. Joo, this should be the accepted answer.
Actually, it's no problem to import JS libraries in Angular, thats how I do it using npm and Angular6:
Run npm install cytoscape
Download Cytoscape from https://github.com/cytoscape/cytoscape.js/blob/master/dist/cytoscape.min.js
Create a directory scripts in your Angular root directory and place the downloaded file there
Include your downloaded script in your angular.json:
"projects": {
"myproject": {
...
"architect": {
"build": {
...
"scripts": [
"src/scripts/cytoscape.min.js"
]
...
(NOTE: Sorry about the formatting, I tried but it does not want to work)
In the Angular component where you want to use Cytoscape, add declare var cytoscape: any; to the imports
Now you can use Cytoscape like you would normally, have fun :)
I have installed and used livescript and its prelude-ls library with bower successfully. I loaded prelude-browser-min.js:
// gulpfile
'static/bower_components/prelude-ls/browser/prelude-browser-min.js',
and I was able to import functions in my application code: {map, filter, lines} = require 'prelude-ls'.
Now I'm removing bower from my stack. I also install livescript and a prelude-ls package with npm but there is no prelude-browser-min.js file anymore (though the doc says to use that). As for javascript files there are a few under a lib directory: index.js, Obj.js, etc. I tried to load them all (prelude-ls/**/*.js) but there is a module.exports line somewhere in them and it fails to load my app ("module is not defined").
If there is no prelude-browser-min.js, how can I do ?
update: related issue: https://github.com/gkz/prelude-ls/issues/73
Allright, I'll keep bower for that then !
This sample grunt file https://gruntjs.com/sample-gruntfile reads in a config object from package.json and stores it in the pkg property:
pkg: grunt.file.readJSON('package.json')
However, the page doesn't give a sample package.json file. Later on it refers to pkg.name. I assume this is a top level key in package.json. E.g.
{
"name": "this value here",
}
Is that correct?
Yes that's correct.
The package.json file is the heart of npm which is used by grunt.
You can generate one for your project using npm initand filling out the options or you can manually create and update it.
It gets updated automatically when using the --save option when adding modules to grunt.
npm install grunt-contrib-copy --save
This will install the module to your node_modules folder and update the dependencies section in your package.json
You only need to save the package.json file in your repo and each developer can download all dependencies listed in your package.json by calling npm install