Using node-canvas in jenkins CI - overriding host to Jenkins-approved host - node.js

How can I override binary-host in node-canvas package.json so it fetches pre-built binariy tarballs from my Jenkins-allowlisted corp server instead of GitHub?
"binary": {
"module_name": "canvas",
"module_path": "build/Release",
"host": "https://github.com/Automattic/node-canvas/releases/download/",
"remote_path": "v{version}",
"package_name": "{module_name}-v{version}-{node_abi}-{platform}-{libc}-{arch}.tar.gz"
},
Otherwise it goes to GitHub.com and errors our since GitHub is not permitted.

npm install canvas --canvas_binary_host_mirror="https://www.makarovcomedy.com" Works, but it doesn't work in yarn.
This works for all:
npm config set canvas_binary_host_mirror https://www.makarovcomedy.com
Source: https://github.com/mapbox/node-pre-gyp/pull/170/files

Related

using the npm API to retrieve a list of private npm packages with versions, possible?

I have a private npm registry with npmjs.org which contains several private npm packages. We are moving to a private npm registry in-house (verdaccio). Long-story short, with our AWS infrastructure, the verdaccio server could be rebuilt for many reasons and the main issue is that when a new server is spun up with a fresh verdaccio install, It won't have any packages published, obviously. I'm trying to create a script that will run when the server is created that will do a few things:
1. Ask the user what the previous npm registry is along with an authToken for a user (is our case, a service user that only the server uses)
2. Query the previous npm registry to get a list of all private scoped packages with all its versions
3. Copy/Migrate/Publish all previously existing packages and versions to the new verdaccio registry so the first person to run "npm install" will get them.
There are several utility packages out there for helping with type of task, but none deal with private packages. I've tried using the authToken from the .npmrc file that gets generated when a user is logged in, from within a curl command, but nothing gets returned. I've tried using the npm search function. I've tried all of these utility packages. I've tried the npm v2 api, but nothing seems to return private packages.
https://www.npmjs.com/package/registry-migrate
https://www.npmjs.com/package/npm-migrate
https://github.com/finn-no/migrate-npm-registry
https://github.com/npm/npm-registry-client
https://api-docs.npms.io/#api-Package-GetMultiPackageInfo
Anyone have any ideas?? Thanks!
You need to add the NPM_TOKEN in the npm registry API.
I found 2 endpoints that can help you perform any necessary logic with the versions of the private npm packages
List all private npm packages names and access
curl -H "Authorization: Bearer $NPM_TOKEN" "https://registry.npmjs.org/-/user/[NPM_USERNAME]/package"
Example response:
{ "my-package": "write" }
** NPM_USERNAME can be the organization's scope.
Fetch npm package details
curl -H "Authorization: Bearer $NPM_TOKEN" "https://registry.npmjs.org/[NPM_PACKAGE_NAME]"
Example response:
{
"_id": "my-package",
"name": "my-package",
"dist-tags": { "latest": "1.0.0" },
"versions": {
"1.0.0": {
"name": "my-package",
"version": "1.0.0"
//...
}
//...
}
}

How to define dependency in package.json for gitrepository?

In my reactjs project I have a dependency on a module that is in another gitrepo(stash) so I created this in my package.json as a property of dependencies :
"somemodule":{
"name": "somemodule",
"dependencies": {
"private-repo": "https://link_to_the_other_repo"
}
}
This repo contains a minified version and non minified version of the same file. When I run npm install the module does not get installed, there is no error message either. How can I create this dependency?
I have managed to get the dist/minified version of the file from the other repo. How can I refer to this in my package.json?
To add a private git module:
If you have RSA key added to your machine(secure & recommended):
"dependencies": {
"package-name": "git+ssh://git#github.com/project/repo.git"
}
If you want https:
"dependencies": {
"package-name": "git+https://username:password#github.com/project/repo.git"
}
Its not recommended to store username, password in your package.json file, so better add ssh keygen to your machine and use the first one.

Failed exitCode=-4071

I am following this guide. Having problem deploying to azure.
https://learn.microsoft.com/en-us/azure/app-service-web/app-service-web-nodejs-sails#step-3-configure-and-deploy-your-sailsjs-app
Full Error
remote: Failed exitCode=-4071, command="D:\Program Files (x86)\nodejs\6.9.1\node.exe" "D:\Program Files (x86)\npm\3.10.8\node_modules\npm\bin\npm-cli.js" install --production
also
remote: npm ERR! EINVAL: invalid argument, rename 'D:\home\site\wwwroot\node_modules\.staging\spdx-license-ids-3f30671f' -> 'D:\home\site\wwwroot\node_modules\sails-hook-grunt\node_modules\grunt-contrib-cssmin\node_modules\maxmin\node_modules\pretty-bytes\node_modules\meow\node_modules\normalize-package-data\node_modules\validate-npm-package-license\node_modules\spdx-correct\node_modules\spdx-license-ids'
Thanks
I do a demo following the tutorials that you mentioned. It works correctly on my side. I used node.js v7.9 locally. If it is possible, please have a try to update the node.js version to latest locally. The following is my details steps.
1.Following the document to install Sails and create a demo project
$npm install sails -g
$sails new test-sails-project
2.go to localhost:1337 to see your brand new homepage
$ cd test-sails-project
$ sails lift
We can check that it works correctly in the local
4.Following the document step by step
a.Add iisnode.yml file with the following code in the root directory
loggingEnabled: true
logDirectory: iisnode
b.set port and hookTimeout in the config/env/production.js
module.exports = {
// Use process.env.port to handle web requests to the default HTTP port
port: process.env.port,
// Increase hooks timout to 30 seconds
// This avoids the Sails.js error documented at https://github.com/balderdashy/sails/issues/2691
hookTimeout: 30000,
...
};
c.hardcode the Node.js version you want to use. In package.json
"engines": {
"node": "6.9.1"
},
5.Create a Azure WebApp on the Azure portal and get the profile.
6.Push the code to the Git remote and check from the Azure portal.

Deploying Hexo on Azure.. not sure what i'm missing

I recently decided to start a small blog for personal use (for now) on Azure. I started digging into the blogging framework Hexo. Now i got the (first) basics under control with starting a Hexo blog locally, but i want to push it to Azure.
I configured a basic web-app with a GIT connection for continuous deployment (https://github.com/lmeijdam/demo-repo). I tried a tutorial with a
server.js file
package.json
.gitignore
Above will result in a working response and installed node_modules... But from there i am really lost about my next steps...
I know you can create a package.json file and viewing my ftp client the package.json is there and also the node_modules folder with the correct modules installed. My package.json;
{
"name": "hexo-site",
"version": "0.0.0",
"private": true,
"hexo": {
"version": "3.1.1"
},
"dependencies": {
"express": "*",
"hexo": "^3.1.0",
"hexo-deployer-git": "0.0.4",
"hexo-generator-archive": "^0.1.2",
"hexo-generator-category": "^0.1.2",
"hexo-generator-index": "^0.1.2",
"hexo-generator-tag": "^0.1.1",
"hexo-renderer-ejs": "^0.1.0",
"hexo-renderer-marked": "^0.2.4",
"hexo-renderer-stylus": "^0.3.0",
"hexo-server": "^0.1.2"
}
}
and i also found out you can deploy a Procfile to the GIT repo which Azure then uses, if you have no default file called server.js (https://github.com/yavorg/azure-node-starter/blob/master/Procfile)
And later a friend came with the tip to edit the procfile to write something like;
web: /node_modules/hexo/bin/hexo server instead of just the web: node server.js
unfortunately this just results in a default blanco webpage... http://lmnodetest1.azurewebsites.net/
Am i doing stuff wrong here or am i forgetting something at the start?
Per my experience, Hexo is a static blog website generator. You can follow these steps below to generate a website at the path "public".
$ hexo init blog
$ cd blog
$ npm install
$ hexo generate
Then, the "public" directory generated, and you can entry into this directory and run the command hexo server to browse http://localhost:4000 to explore your blog.
$ cd public
$ hexo server
For deploying the blog into Azure Website by using Git, you just need to create a local git repo by commanding git init at the "public" dir.
Please refer to the doc https://azure.microsoft.com/en-us/documentation/articles/web-sites-deploy/ to deploy it into Azure.
Best Regards.
Here are the steps that I do to run Hexo blog on Azure: http://the-coderok.azurewebsites.net/2015/09/16/Running-Hexo-blog-on-Azure/
It seems to me that the best part about using hexo is as a static site generator. The hexo server is really meant to give you a nice development environment where you can see your posts right away, but if you're publishing your site you'd wanna serve the statically generated content to remove node from the picture.
Hexo has hexo generate for that and you can get that to work nicely with Azure if you have a custom deployment script.
Here is a repo with 2 commits that you can git push to an empty site and it'll create a working static hexo blog:
First commit is just the result of hexo init blog
Second commit is the custom deployment script. You'd want to copy these 2 files to your own repo.
here is the exact parts that you'd need in your deploy.cmd for hexo.
note that the actual script in the repo has way more lines for proper error handling but this is just the gist of what you need
echo Handling Hexo deployment.
IF NOT DEFINED HEXO_PATH (
echo Setting HEXO_PATH to %HOME%\npm_tools\hexo.cmd
set HEXO_PATH="%HOME%\npm_tools\hexo.cmd"
)
IF NOT EXIST %HEXO_PATH% (
echo Hexo CLI isn't installed. Running 'npm install hexo-cli -g'
mkdir "%HOME%\npm_tools"
npm config set prefix "%HOME%\npm_tools"
npm install -g hexo-cli
)
echo Running 'npm install --production'
npm install --production
echo Running 'hexo generate'
%HEXO_PATH% generate
echo Copying static content to site root
"%KUDU_SYNC_CMD%" -v 50 -f "public" -t "%DEPLOYMENT_TARGET%" -n "%NEXT_MANIFEST_PATH%" -p "%PREVIOUS_MANIFEST_PATH%" -i ".git;.hg;.deployment;deploy.cmd"
I took a quick look at your site. The issue appears to be that you have a server2.js file but no server.js file. Can you try renaming it in your repo and pushing again? That should at least get you past the first hurdle.

Unable to install npm package hosted on a private registry with jspm

I am trying to get jspm working with a private npm registry (which mirrors the public registry).
I used the endpoint config tool to configure jspm from .npmrc appears to work successfully
GAVINJ:jspm-test gavinj$ jspm endpoint config npm
npmrc found, would you like to use these settings? [yes]:
npm registry [http://registry.npm.ourcompanyname.net/]:
Would you like to test these credentials? [yes]:
ok npm authentication is working successfully.
ok Endpoint npm configured successfully.
Installing our package 'michelangelo' (which is not in the public npm registry) works just fine
GAVINJ:jspm-test gavinj$ npm install michelangelo
highstock-release#2.0.4 node_modules/highstock-release
jquery#2.1.3 node_modules/jquery
d3#3.5.5 node_modules/d3
lodash#3.3.1 node_modules/lodash
michelangelo#2.0.1641 node_modules/michelangelo
Attempting to install the same npm package via jspm does not work.
GAVINJ:jspm-test gavinj$ jspm install michelangelo=npm:michelangelo
Looking up npm:michelangelo
err Repo michelangelo not found!
warn Installation changes not saved.
Attempting to install lodash via jspm works perfectly
GAVINJ:jspm-test gavinj$ jspm install lodash=npm:lodash
Looking up npm:lodash
Updating registry cache...
Looking up github:jspm/nodelibs-process
Looking up npm:process
ok Up to date - lodash as npm:lodash#^3.3.1 (3.3.1)
ok Install tree has no forks.
ok Install complete.
Here's what my jspm config file looks like
{
"registry": "jspm",
"endpoints": {
"github": {
"timeouts": {
"lookups": 60
},
"handler": "jspm-github",
"remote": "https://github.jspm.io"
},
"npm": {
"timeouts": {
"lookups": 60
},
"registry": "http://registry.npm.ourcompanyname.net/",
"remote": "https://npm.jspm.io",
"auth": "PRIVATE_HERE_BUT_SAME_AS_NPMRC_FILE",
"handler": "jspm-npm"
},
"jspm": {
"timeouts": {
"lookups": 60
},
"handler": "jspm-registry",
"remote": "https://registry.jspm.io"
}
}
}
Any idea why I am unable to install the npm pacakge via jspm? Or, any advice on how I could track down the problem?
It turns out that the registry url cannot end with a /.
Once I removed the trailing slash it worked like a charm.

Resources