Npm command ignoring flags - npm

I am using the following command,
npm run ng build --watch
Running
> json#0.0.0 ng C:\Users\json
> ng "build"
It ignoring the watch flag, can any one help me on this.
Please don't get into why I am using npm run ng build --watch that is a big story.

Found a workaround for this, in package.json added build:dev as new command and running npm run build:dev solves my issue
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"build:dev": "ng build --watch"
},

Related

npm build failure in Azure deveops pipline

I am facing this issue while building dist file in azure devops pipeline:
enter image description here
peice of code in package.json file is:
"name": "aimportal",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build --prod --aot --vendor-chunk --common-chunk --delete-output-path --buildOptimizer --output-hashing none --watch",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
angular version : 9.0.1
I tride by deleting package.json file and added the same node js version but still facing the issue.

How can I make the cross-env and nodemon work together?

This is my package.json fragment.
"scripts": {
"build": "react-scripts build",
"dev": "cross-env NODE_ENV=development run-p server start",
"eject": "react-scripts eject",
"prod": "cross-env NODE_ENV=production node server",
"server":"nodemon -r dotenv/config ./server/index.js",
"start": "react-scripts start",
"test": "react-scripts test"
},
When I execute the following command:
npm run dev
The nodemon working properly.
However, when I execute the following command:
npm run prod
The nodemon seems to be not working. When I change the content of ./server/index.js, the file is not reloaded.
It works when changing the following statement:
"prod": "cross-env NODE_ENV=production node server",
to
"prod": "cross-env NODE_ENV=production nodemon -r dotenv/config ./server/index.js",
However, I don't want to duplicate the following phase:
"nodemon -r dotenv/config ./server/index.js".
So, would you tell me how I can make it work as expected?
You should use the nodemon.json config file.
For example:
nodemon.json
{
"watch": ["src"],
"ext": "ts, js, json",
"execMap": {
"ts": "cross-env NODE_ENV=development ts-node -T"
}
}
and into the package.json you call nodemon normally. For example:
{
...
"scripts": {
"start:dev": "nodemon ./src/server.ts",
}
}
This is an usage example with typescript but you can readjust to nodejs
Finally, I found the solution.
"scripts": {
..........
"dev": "cross-env NODE_ENV=development run-p server start",
"eject": "react-scripts eject",
"prod": "cross-env NODE_ENV=production npm run server",
"server":"nodemon -r dotenv/config ./server/index.js",
..........
},

entry pattern "'./src/components/*.vue'" did not match any files / Building Web Components VUEJS

"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"wbuild": "vue-cli-service build --watch",
"lint": "vue-cli-service lint",
"build:target": "vue-cli-service build --target wc --name my-compo './src/components/*.vue'"
},
I have two questions:
First: When I follow the documentation of "documents Build Target Vue.js" and I use npm run build:target, it does not work like mentioned in the documentation, but when I try to remove the single quotes ' ' then it does work, can someone explain this behaviour?
Second: Can I replace --name my-compo with name in the .vue file?
I want to have for example:
alert.vue -> my-compo.js -> alert.js
Maybe it helps you to install https://www.npmjs.com/package/cross-env and prefix your script commands with cross-env like:
"scripts": {
"serve": "cross-env vue-cli-service serve",
"build": "cross-env vue-cli-service build",
"wbuild": "cross-env vue-cli-service build --watch",
"lint": "cross-env vue-cli-service lint",
"build:target": "cross-env vue-cli-service build --target wc --name my-compo './src/components/*.vue'"
},
The reason can be that your are also in windows, like me.

Vue app with WebStorm in mac npm ERR! missing script: dev

I am trying to create a Vue App with WebStorm in Mac. When I run the npm run dev get this error:
npm ERR! missing script: dev
This is my package.json:
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"vue": "^2.5.16"
},
"devDependencies": {
"#vue/cli-plugin-babel": "^3.0.0-beta.15",
"#vue/cli-plugin-eslint": "^3.0.0-beta.15",
"#vue/cli-service": "^3.0.0-beta.15",
"vue-template-compiler": "^2.5.16"
},
That's because there's no dev script in your package.json. You should do npm run serve. The available scripts are the following
package.json
// ...
"scripts": {
"serve": "vue-cli-service serve", // npm run serve
"build": "vue-cli-service build", // npm run build
"lint": "vue-cli-service lint" // npm run lint
},
// ...

WebStorm npm scripts: ng build --prod

I'm wanting to run ng build --prod with WebStorm, however it only seems to do ng build and misses the --prod command.
I'm wanting to run this in WebStorm, not in the terminal.
Note: if I add --prod to Arguments, it doesn't work:
/usr/local/bin/node /usr/local/lib/node_modules/npm/bin/npm-cli.js run build --scripts-prepend-node-path=auto --prod
> cosmoline#0.0.0 build /Users/robertking/go/src/gitlab.com/cosmoline_client
> ng build
You could add --prod to the build script inside of the package.json. For example:
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build --prod",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
Or add an alternate step:
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"build:prod": "ng build --prod",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
If you don't want to do it in the package.json file, since WebStorm isn't running ng directly (it's running via npm), it may not be passing the attributes.
Adding an additional -- may work (e.g. -- --prod).
Or try putting it in quotes (e.g. "--prod").