JSPM can't install (404 from github) BUT CAN install from npm - javascript

This is truly frustrating.
Package.json for a repo hosted on github as part of my organisation. I am trying to pull this in via jspm.
{
"name": "tf-modernizr",
"version": "1.0.0",
"description": "",
"main": "modernizr.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/tomorrowfinance/tf-modernizr.git"
},
"author": "Simon Douglas",
"license": "MIT",
"bugs": {
"url": "https://github.com/tomorrowfinance/tf-modernizr/issues"
},
"homepage": "https://github.com/tomorrowfinance/tf-modernizr#readme",
"directories": {}
}
npm install works fine (!!!)
running jspm install:
jspm install github:tomorrowfinance/tf-modernizr#master
or jspm install github:tomorrowfinance/tf-modernizr informs me there is a 404.
Looking up github:tomorrowfinance/tf-modernizr
Updating registry cache...
Downloading github:tomorrowfinance/tf-modernizr#master
warn Error on download for github:tomorrowfinance/tf-modernizr
Bad response code 404
err Error downloading github:tomorrowfinance/tf-modernizr.
The documentation here http://jspm.io/docs/getting-started.html doesn't help. The documentation here https://github.com/jspm/registry/wiki/Configuring-Packages-for-jspm is complex. What am I missing?

Since this is a private repository, you need to allow jspm to access it.
Simply configure access to github using: jspm registry config github

Related

Can't build Ember.js app embedded in Rails app on Heroku

Trying to build Ember.js app embedded in Rails app on Heroku, but get this error:
Could not require 'ember-cli-build.js': Cannot find module 'ember-cli/lib/broccoli/ember-app'
Rail's package.json:
{
"name": "foo",
"license": "MIT",
"engines": {
"node": "9.5.0",
"yarn": "1.22.4"
},
"scripts": {
"build": "yarn global add ember-cli#2.9.0 --ignore-engines && yarn --cwd ember install --ignore-engines && yarn --cwd ember build"
}
}
Ember's package.json:
{
"name": "foo",
"version": "0.0.0",
"description": "foo",
"private": true,
"directories": {
"doc": "doc",
"test": "tests"
},
"scripts": {
"build": "ember build",
"start": "ember server",
"test": "ember test"
},
...
}
This Ember.js app as stand-alone, i.e. not being embedded in Rails app, is deployed on Heroku without errors.
I've found an answer by myself via inspecting the log of successful deployment of stand-alone Ember app. All that needs to be done is to run the following in terminal before deployment:
heroku config:set NPM_CONFIG_PRODUCTION=false

Cannot run percy snap shot test in Testcafe error message: npm ERR! missing script: test:percy

I'm running my first test using percy snapshot using the following command
npm run test:percy
. I got the following error message:
xxx.xxx#LPG002572 TC-Visual % npm run test:percy
npm ERR! missing script: test:percy
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/xxx.xxx/.npm/_logs/2020-04-06T16_11_45_122Z-debug.log
jacqueline.george#LPG002572 TC-Visual % npm run test:percy
npm ERR! missing script: test:percy
However my package.json which I double checked seems to be correct. What did I do wrong, and how do I fix it?
{
"name": "tc-visual",
"version": "1.0.0",
"description": "Visual testing with TestCafe and Percy.io",
"main": "index.js",
"scripts": {
"test": "percy exec -- testcafe chrome ./tests"
},
"keywords": [
"TestCafe",
"percy"
],
"author": "xxx xxx",
"license": "ISC",
"dependencies": {
"#percy/testcafe": "^0.2.0",
"testcafe": "^1.8.3"
}
}
The root cause of this problem is that under 'tests' in the package Json. I made an omission. This is very easy to do. So if anyone else is experiencing this issue please be careful because when you modify your package json. As you can see in the updated code I added test:percy
Please see the updated package json with the correct information
{
"name": "tc-visual",
"version": "1.0.0",
"description": "Visual testing with TestCafe and Percy.io",
"main": "index.js",
"scripts": {
"test:percy": "percy exec -- testcafe chrome ./tests"
},
"keywords": [
"TestCafe",
"Percy"
],
"author": "Author",
"license": "ISC",
"dependencies": {
"#percy/testcafe": "^0.2.0",
"testcafe": "^1.8.3"
}
}
This worked for me.
$ percy exec -- testcafe chrome ./tests
'percy' is not recognized as an internal or external command,
operable program or batch file.
error Command failed with exit code 1
.
yarn add percy or npm install percy
Also percy client was needed after getting this error: Unsupported Percy CLI version, disabling snapshots.
npm install --save-dev #percy/cli

How to make npx work with my custom npm pakage?

I've published a new package which aims to generate a very small boilerplate for a node open source project via cli. For now, it's just a combination of few npx commands and requires other npm packages like gitignore, license to work. I want to execute the build script in package.json with the following command.
npx get-set-node-oss build youremailaddress#xyz.com
Link to the npm package: get-set-node-oss. I know the name is a bit too long.
{
"name": "get-set-node-oss",
"version": "1.0.1",
"description": "One command setup for your Node OSS project",
"scripts": {
"build": "npx license mit > LICENSE && npx gitignore node && npx covgen"
},
"author": "Harshit Juneja",
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/harshitjuneja/get-set-node-oss.git"
},
"keywords": [
"node",
"boilerplate","gitignore","MIT","OSS"
],
"bugs": {
"url": "https://github.com/harshitjuneja/get-set-node-oss/issues"
},
"homepage": "https://github.com/harshitjuneja/get-set-node-oss#readme"
}
I expect the user to make a new folder and cd into the folder and do
npx get-set-node-oss build emailstring
and get the resulting boilerplate files.
For npx to work you need to specify what the get-set-node-oss command means. Thankfully, this can be accomplished by using the bin field in your package.json file. More information from NPM documentation for your reference:
To use this, supply a bin field in your package.json which is a map of command name to local file name. On install, npm will symlink that file into prefix/bin for global installs, or ./node_modules/.bin/ for local installs.
An example of it below.
"bin": {
"get-set-node-oss": //script you like to run
},
Hope it works out for you. I have understood bin as scripts in package.json. Where we can either do npm run foo or npx foo both yielding the same results. If you want an example, here you go https://github.com/vipulgupta2048/balenaclone

npm ERR Refusing to install package with name <packageName> under a package also called <packageName>

I am trying to use the jsonfile package in my project, but I get the following errors:
Refusing to install package with name <packagename> under a package also called <packagename>. (Note that none of the directory or filename is same as package name)
Cannot find module <packagename>.
The problem is caused when the name of project in package.json is the same as the module you're trying to install.
To solve this problem, please change the project name in package.json to something else. For example, "jsonfile-test":
{
"name": "jsonfile-test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
}
}
I think it should be:
npm install --save json-file
not
npm install --save jsonfile
ref: https://www.npmjs.com/package/json-file
If that does not work please try enabling permissions install - e.g. (on mac- but will be equivalent on windows, check: https://helpdeskgeek.com/free-tools-review/5-windows-alternatives-linux-sudo-command/) run:
sudo npm install --save json-file

Botkit hoek vulnerability

I cannot figure out how to update a dependent package included in Botkit. After running npm install on the package.json below. Npm warns that the hoek package is vulnerable. I've tried running npm audit fix with no resolution. When I run npm ls hoek it shows botkit installed hoek#2.16.3. I don't see why it would install an out of date version.
//package.json
{
"name": "deleteme",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"botkit": "^0.6.16"
}
}
From the npm documentation:
As of npm#2.6.1, the npm update will only inspect top-level packages.
Prior versions of npm would also recursively inspect all dependencies.
To get the old behavior, use npm --depth 9999 update.
See more details here: https://docs.npmjs.com/cli/update

Categories

Resources