I would like to download via npm or bower dojo version 1.11.0-pre.
At the moment I am using the following package.json file but npm is not able to find the dependencies.
How to solve this issue and load dojo 1.11.0-pre?
{
"dependencies": {
"dojo": "1.11.0-pre"
}
}
EDIT
{
"dependencies": {
"dojo": "https://github.com/dojo/dojo.git#a275e8237cd8be0a4e3af4d229853f317bc56873"
},
"description": "fe",
"name": "fe",
"version": "0.0.0"
}
It's possible use github as dependence:
{
"dependencies": {
"dojo": "https://github.com/dojo/dojo.git#a275e8237cd8be0a4e3af4d229853f317bc56873"
}
https://docs.npmjs.com/files/package.json#github-urls
Related
I have a app project and 2 node module projects.
The dependencies structure is something like this:
App {
NodeModule1 {
NodeModule2,
...
},
...
}
The problem I have is that my NodeModule2 instead of being installed on the root of app's node_module App/node_modules/NodeModule2, it is installed in App/node_modules/NodeModule1/node_modules/NodeModule2
This is causing some error on runtime, says my NodeModule2 is not found. My workaround is to add NodeModule2 into App directly, which is not an idea solution.
All other dependencies of NodeModule1 are installed at App/node_modules/.. as expected.
My NodeModule2's package.json
{
"name": "NodeModule2",
"version": "0.0.2-20210202.1.0",
"private": false,
"description": "",
"author": "",
"license": "ISC",
"peerDependencies": {
"react": "16.13.1",
"react-native": "0.59.10",
...
}
}
I HAVE GOT IT
In order for sub node_module to be appeared on the root level, all its peerDependenciess' versions must be matched with App's.
In my case both of my App and NodeModule1 has dependency of react-native-picker-select but with different versions.
App {
dependency: {
"react-native-picker-select": "^8.0.0"
}
}
NodeModule1 {
dependency: {
"react-native-picker-select": "8.0.0"
}
}
NodeModule2 {
peerDependency: {
"react-native-picker-select": "8.0.0"
}
}
In this case, App received 8.0.4 and NodeModule1 received 8.0.0.
Yarn puts NodeModule2 under NodeModule1 and to shared the same dependency version 8.0.0.
Fix: Make sure all versions are matched in App, NodeModule1, and NodeModule2.
i'm having a hard time to understand how to run all of my .js files using package.js files
i have almost 2000.js scripts i need to run them one by one, i'm using a api made by gameflip
in the folder i found package.js, but i don't know how to use it ,
can anyone tell me how to do that ? thank you
here the script :
{
"name": "gfapi",
"version": "0.1.1",
"description": "Gameflip API",
"keywords": "Gameflip",
"homepage": "https://github.com/iJJi/gfapi",
"bugs": "https://github.com/iJJi/gfapi/issues",
"author": {
"name": "Eng-Shien Wu",
"email": "engshien.wu#ijji.com"
},
"license": "MIT",
"private": true,
"files": [
"index.js"
],
"repository": "iJJi/gfapi",
"engines": {
"node": ">=8.5.0"
},
"scripts": {
"bulk_listing": "node src/samples/bulk_listing.js",
"test": "ENVIRONMENT=mocha mocha src/test --recursive",
"docs": "jsdoc -c jsdoc_conf.js -d docs -P package.json index.js; docco -o docs/samples src/samples/*.js src/samples/*.rb"
},
"dependencies": {
"base-64": "^0.1.0",
"bluebird": "^3.5.0",
"bunyan": "^1.8.12",
"file-type": "^8.1.0",
"http-errors": "^1.6.2",
"node-rest-client-promise": "^3.1.1",
"promise-ratelimit": "^0.0.3",
"request": "^2.85.0",
"request-promise": "^4.2.2",
"speakeasy": "^2.0.0"
},
"devDependencies": {
"marked": "^0.3.19",
"docco": "^0.7.0",``
"jsdoc": "^3.5.5"
}
}
What you posted isn't a package.js (I don't even know if it exists), but a package.json. It's generated by NPM, the Node Package Manager. It's a list of all the project's dependencies. I think that what you're looking for are the npm scripts, they are in the script object of package.json.
npm run <script>
# For example :
npm run bulk_listing
npm run test
npm run docs
Each script will run its associated command in this package.json.
npm run bulk_listing
# Will do the same thing as:
node src/samples/bulk_listing.js
More about package.json.
The script I talked about below
If you want to run all the scripts, this should do the job :
const fileNames = ["path/to/fileA", "fileB"]; // I assume you have something to get all the files path. Isn't that npm run bulk_listing ?
fileNames.forEach(async (path, index) => {
// It's pretty much like 'node <path>'
await require(path);
// All the code here is executed AFTER the script has been launched
console.log(`LAUNCHED ${index} | ${path}`)
});
I'm using parcel to process typescript for a webextension.
JQuery and its type definitions are installed via npm.
At the top of my typescript file I have:
import $ from "jquery";
import "bootstrap";
But at runtime, Chrome complains that jquery is not defined.
A minimal example to reproduce the problem is on git: https://github.com/lhk/parcel_jquery_bug_demo
git clone https://github.com/lhk/parcel_jquery_bug_demo
cd parcel_jquery_bug_demo
npm install
parcel build src/manifest.json
Now you can open chrome and load the dist folder
The git repo contains:
src/manifest.json
{
"manifest_version": 2,
"name": "pc",
"version": "0.0.1",
"description": "none",
"author": "",
"content_security_policy":"script-src 'self'; object-src 'self'",
"content_scripts": [
{
"matches": ["<all_urls>"],
"js": [
"./content/index.ts"]
}
]
}
src/content/index.ts
import $ from "jquery";
import "bootstrap";
$(function () {
$('[data-toggle="popover"]').popover();
});
./package.json
{
"name": "pc",
"version": "0.1.0",
"description": "",
"author": "",
"license": "",
"devDependencies": {
"parcel-plugin-web-extension": "^1.4.0",
"typescript": "^3.1.3"
},
"dependencies": {
"#types/bootstrap": "^3.3.7",
"#types/jquery": "^3.3.10",
"bootstrap": "^3.3.7",
"jquery": "^3.3.1"
}
}
After you loaded the extension in chrome, you can load any website.
The error message is:
Uncaught ReferenceError: jQuery is not defined
I'm using:
Parcel 1.10.1
Node v8.12.0
npm 6.4.1
ubuntu 18.04.1 64bit
chrome 70
I think this problem is related to the import of bootstrap. The following code works:
import $ from "jquery";
//import "bootstrap";
$(function () {
//$('[data-toggle="popover"]').popover();
$('[data-toggle="popover"]').click(function(){});
});
So the dependency of my typescript code is actually handled by parcel. But bootstrap also needs jQuery and that is somehow not satisfied.
Parcel actually takes no part in the issue, it is mostly that jQuery/Bootstrap relies on the $ and jQuery function being exposed in the global scope.
This is fairly simple to archive by doing the following (for JS only, since TS will complain about window not having the property $ and jQuery):
import jquery from "jquery";
window.$ = window.jQuery = jquery;
import "bootstrap";
But since you're using TypeScript you will need to do more in order to get the linting and intellisense support working too.
Install the TypeScript definition file npm install --save-dev #types/jquery #types/bootstrap
use import * as $ from 'jquery'; to import it.
Configure the libs for the DOM api since they are not enable by default for TypeScript, this will allow you to use a proper window and document but you
need to change window to (<any> window)
tsconfig.json
{
"compilerOptions": {
//...
"lib": ["dom"],
//...
},
}
I added a babel plugin (babel-plugin-auto-import) with this .babelrc
{
"plugins": [[
"auto-import", {
"declarations": [
{ "anonymous": ["jQuery"], "path": "jquery" }
]
}
]]
}
Everything seems to be working.
New package.json
{
"name": "pc",
"version": "0.1.0",
"description": "",
"author": "",
"license": "",
"devDependencies": {
"babel-core": "^6.26.3",
"babel-plugin-auto-import": "^0.9.3",
"parcel-plugin-web-extension": "^1.4.0",
"typescript": "^3.1.3"
},
"dependencies": {
"#types/bootstrap": "^3.3.7",
"#types/jquery": "^3.3.10",
"bootstrap": "^3.3.7",
"jquery": "^3.3.1"
}
}
I'm working with highcharts-browserify. This is what my package.json file looks like:
{
"main": "index.js",
"scripts": {
"watch-index": "watchify index.js -o ../../static/js/index.js --debug --verbose",
"watch": "npm run watch-index",
"build-index": "browserify index.js | uglifyjs > ../../static/js/index.min.js",
"build": "npm run build-index"
},
"dependencies": {
"highcharts-browserify": "^0.1.5-4.1.7",
"jquery": "^1.11.3",
}
}
However, when I run npm run watch, the compiled file has v4.0.4 of Highcharts in it, not the latest version (v4.1.7).
How can I make sure I've got the latest version?
I need to use the latest version because of this bug in x-axis labels in v4.0.4 of Highcharts: http://jsfiddle.net/5z8rf83y/7/
The highcharts-browserify library currently uses v 4.0.4.
https://github.com/soldair/highcharts-browserify/blob/master/highcharts.js#L2
You could open a ticket to have it updated, or fix it and submit a pull request.
Also, you can by pass using this library, and use browserify-shim which would look like this -
{
"browserify": {
"transform": [
"browserify-shim"
]
},
"browserify-shim": {
"Highcharts": {
"depends": ["HighchartsAdapter:HighchartsAdapter"],
"exports": "Highcharts"
},
"HighchartsAdapter": {"exports":"HighchartsAdapter"}
},
"browser": {
"Highcharts": "./bower_components/highcharts-release/highcharts.src.js",
"HighchartsAdapter": "./bower_components/highcharts-release/adapters/standalone-framework.src.js"
}
}
I've a package.json like this:
{
"name": "some-module",
"version": "1.0.0",
"bin": "./bin/some-module.js",
"main": "./bin/some-module.js",
"description": "Some module description",
"homepage": "http://my.home.page.com",
"author": {
"name": "Matias Fidemraizer",
"email": "no-email#no-email.com",
"url": "http://some.url.com"
},
"engines": {
"node": ">=0.4.0"
},
"keywords": [
"somekeyword"
],
"license": {
"type": "Apache v2",
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
},
"preferGlobal": true,
"repository": {
"type": "git",
"url": "git://github.com/some/repo"
},
"dependencies": {
"somedependency": "*"
}
}
When I try to install the whole module typing npm -g install /path/to/module/folder, npm creates a .cmd file on AppData folder in the default node_modules location for global installations as expected.
But generated code doesn't include node.exe or node:
"%~dp0\node_modules\some-module\bin\some-module.js" %*
... so when I try to execute my some-module module in CMD, PowerShell or whatever, it's executed using Windows Script Host (WSH).
For that reason I thought comparing package.json of some existing module like YUIDocJS would be enough to find out what's causing this problem but I can't figure out what's wrong in my own package.json so it doesn't create the expected global installation.
Thank you in advance for your effort.
Do you have the shebang #!/usr/bin/env node at the top of the file referenced in the bin property of your package.json? Even though the shebang is a *nix specific directive, npm depends on its presence to create the shim for the .cmd