I am using command ng add #angular/material
Unable to fetch package metadata: Cannot read property 'startsWith' of null is the error I am getting npm config list [-l] [--json];
cli configs metrics-registry = "https://artifacthub-tip.oraclecorp.com/api/npm/npmjs-remote" scope = "" user-agent = "npm/6.12.0 node/v12.13.0 win32 x64";
userconfig C:\Users\goparao\.npmrc
http_proxy = "http://registry.npmjs.org/"
key = "value"
registry = "https://artifacthub-tip.oraclecorp.com/api/npm/npmjs-remote"
strict-ssl = true;
builtin config undefined prefix = "C:\\Users\\goparao\\AppData\\Roaming\\npm"; node bin location = C:\Program Files\nodejs\node.exe ;
cwd = D:\angular_practice\hello-world ;
HOME = C:\Users\goparao ;
"npm config ls -l" to show all defaults.
PS D:\angular_practice\hello-world>
If you still have issues to install Angular Material, you can first install it with the command : npm i #angular/material then run the command ng add #angular\material. (Worked with Angular 10)
Related
I just use node and npm, I don't need go, python or ruby on netlify build. Can i skip it at netlify build?
I've tried to put it into netlify.toml using variable, like below code :
[build]
command = "pnpm build || ( npm install pnpm && pnpm build )"
publish = "build"
[build.environment ]
NODE_VERSION = "16.14.0"
GO_VERSION = false
RUBY_VERSION = false
PYTHON_VERSION = false
But it will give me error like this
: json: cannot unmarshal bool into Go struct field BuildConfig.Config.build.environment of type string
I have created a command in package.json file
"create": "ng g component process.env.page --it false"
Now I want to access the passed page argument in the above command so that user can pass the component name to the npm command
I am running the above command as
npm run create --page login
and this runs the
ng g component process.env.page --it false
so new component is created with name process.
How can I access the passed page (login) in my script?
You can use the primitive process.argv or yargs which is a lot more powerful
here is a yargs example
const argv = require("yargs").argv;
let page = argv.page //get the page
The syntax of npm run is:
npm run <command> [-- <args>]
So you need to pass -- before your args. Your command should be as follows:
npm run create -- --page login
const minimist = require('minimist');
let args = minimist(process.argv.slice(2), {
default: {
port: 8080
},
});
run with
npm run start -- --port=8090
args contains
args: { _: [], port: 8090 }
So I have a sbt project that uses sbt-js-engine and sbt-webpack plugins.
It successfully gets and resolves npm packages just fine. And then webpack would build the project.
I have added a npm install script into package.json like so,
"scripts": {
"install": "bower install"
}
However, the problem I am currently having is that when I run webpack (which intern uses sbt-js-engine ) it runs npm update instead of npm install.
Heres an excerpt of my build.sbt,
lazy val common = project.in(file("common")).
enablePlugins(SbtWeb).
settings(
sourceDirectory in webpack := baseDirectory.value,
resourceManaged in webpack := (resourceManaged in webpack in root).value,
includeFilter in webpack := ("*.jsx" || "*.js" || "*.json") && new FileFilter {
#tailrec
override def accept(pathname: File): Boolean = {
if (pathname == null) false
else if (pathname.getName == "javascripts") true
else accept(pathname.getParentFile)
}
},
JsEngineKeys.engineType := JsEngineKeys.EngineType.Node
)
Is there anyway I could run npm install instead or even before as a depedency for webpack task ?
You could try something like this:
sourceDirectory in webpack := {
Process("/usr/local/bin/npm install", file("[path to working dir]")).!
baseDirectory.value
}
That would mean it would run at same time as setting the webpack settings.
Next script goes thought all folders and installs dependencies
var fs = require( "fs" ),
path = require( "path" ),
child_process = require( "child_process" );
var rootPath = "./";
var dirs = fs.readdirSync( rootPath )
.filter( function( dir ) {
return fs.statSync( path.join( rootPath, dir )).isDirectory();
});
var install = function()
{
if ( dirs.length === 0 )
return;
var dir = dirs.shift();
console.log( "installing dependencies for : '" + dir + "'" );
child_process.exec( "npm prune --production | npm install", {
cwd: rootPath + dir
}, install );
};
install();
How to run npm install command only if package.json exists in folder?
Try this command:
ls | grep package.json && (npm prune --production | npm install)
I assume you are running this in Linux.
In theory, if I remember correctly, the ouput of the command ls will be piped to the grep command, and only if the grep command will have found a result, then the commands (npm prune --production | npm install) will be executed.
This is not tested by me at the moment of writting this, since I don't have a Linux box right now to test this, but I hope it works.
UPDATE:
The efficient command, as per Dan's comment would be
test -f package.json && (npm prune --production | npm install)
when I run npm install I get a very long error saying error parsing json and continues with the source code of a HTML page that tells me I have a '407 Proxy Authentication Required' error.
The full log can be seen here: http://pastebin.com/T7a4zuYK
this is what npm config list returns:
; cli configs
registry = "http://registry.npmjs.org/"
user-agent = "npm/1.4.28 node/v0.10.34 win32 x64"
; userconfig C:\Users\PV01054\.npmrc
https-proxy = "http://localhost:3128/"
proxy = "http://localhost:3128/"
registry = "http://registry.npmjs.org/"
; builtin config undefined
prefix = "C:\\Users\\PV01054\\AppData\\Roaming\\npm"
; node bin location = C:\Program Files\nodejs\\node.exe
; cwd = C:\Repos\randstad-nl
; HOME = C:\Users\PV01054
; 'npm config ls -l' to show all defaults.