I am trying to run my gulp lint task in my npm script like this, part of the package.json:
"lint":"cd somedirectory && npm run gulp-lint"
"gulp":"gulp",
"gulp-lint": "gulp --lint"
When I run npm run lint I get this error:
missing script : gulp-lint
How can I call the gulp task lint?
Related
I am trying to change the {variable} part in my custom-defined npm run deploy script
"scripts":{
"deploy": "npm run build && scp -r ./public example#192.200.0.11:/home/{DIRECTORY}/index.js",
}
I want to run it like npm run deploy --DIRECTORY:project99
You can pass arguments to npm run as Environment variable. See Npm Docs
"scripts": {
"deploy": "npm run build && scp -r ./public example#192.200.0.11:/home/${NPM_CONFIG_DIRECTORY}/index.js"
},
This should work
npm run deploy --DIRECTORY=project99
I am using Cypress and I have the following scripts:
"merge:reports": "mochawesome-merge mochawesome-report/*.json > cypress-combined-report.json",
"create:html:report": "npm run merge:reports && marge --reportDir final-report cypress-combined-report.json",
"delete:reportFolder": "if exist mochawesome-report rmdir /Q /S mochawesome-report && if exist final-report rmdir /Q /S final-report",
"start": "npm run delete:reportFolder && npx cypress run --browser chrome && npm run merge:reports && `enter code here`npm run create:html:report"
What I want is all those scripts running sequentially but I think there is something I am missing here as I am not that familiar with npm and npx as when I trigger this script only it is passing:
npx cypress run --browser chrome
But when I try to execute the script with all the 4 scripts I am getting an error which I think is due to having a npx script:
npm run start
Would be glad for any suggestions or advices where I am wrong, thanks!
If it is unintentional I could see enter code here written for start, please remove that and try running afterwards.
Delete the node_modules folder and package-lock.json files. Then run npm i to install all the dependencies again and then again try running npm run start
Or Remove npx from the cypress run:
"start": "npm run delete:reportFolder && cypress run --browser chrome && npm run merge:reports && npm run create:html:report"
I have a simple git repository https://github.com/alexey-sh/test_webpack_with_npm
I want to use it as npm dependency but without publishing in npm.
So in other words I want to install the package in my another repository as dependency.
npm i --save git+https://github.com/alexey-sh/test_webpack_with_npm.git
But I want to use a modern js in my test_webpack_with_npm project and compile it into old javascript after package installation process. To achieve it I created npm scripts (test_webpack_with_npm package)
"scripts": {
"install": "npm run build",
"build": "webpack --mode production --config webpack.config.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
so now there's a weird thing:
if I run npm run build from test_webpack_with_npm repository I can get dist/index.js without class declaration (as I expected).
but if I install the package via the following command
npm i --save git+https://github.com/alexey-sh/test_webpack_with_npm.git
I get another type of dist/index.js and there are class declaration.
How can I install the test_webpack_with_npm properly? I want to see old js in node_modules/test_webpack_with_npm/dist/index.js.
Steps to reproduce:
mkdir my_test_project
cd my_test_project
npm init
npm i --save git+https://github.com/alexey-sh/test_webpack_with_npm.git
check node_modules/test_webpack_with_npm/dist/index.js
Thanks!
the fix is very simple. just replace exclude with include in webpack config
include: path.join(__dirname, 'sources'),
that works perfectly.
updated config goes here https://github.com/alexey-sh/test_webpack_with_npm/blob/master/webpack.config.js
I am looking for a cross-platform way of conditionally running a step in my build script.
I have a build step that is expensive, however checking to see if it is necessary is relatively quick. I have created a script that returns a non-zero error code if it is not necessary to do the build step. How can I write my npm script to only run the build if the check passes but provide errors if the build step fails?
Example package.json:
"scripts": {
"schema:build": "npm run schema:rebuild-check && npm run schema:force-build",
"schema:rebuild-check": "node tools/schema is-rebuild-necessary",
"schema:force-build": "npm run schema:validate && npm run schema:generate-index && npm run schema:bundle"
}
The problem with the above is that if the rebuild is not necessary my entire build fails. I can't just swallow the exit code with something like exitzero because I want to know if any of the commands fail in the schema:force-build script.
The problem arises from two things:
1) If an npm script exits with a non-zero code npm will always complain
2) Need to provide an "else" that returns non zero using the || operator
Working solution:
"schema:build": "node tools/schema is-rebuild-necessary && npm run schema:force-build || echo Skipping schema build",
"schema:force-build": "npm run schema:validate && npm run schema:generate-index && npm run schema:bundle"
I'm new to CI Builds in VSTS and as a result, having a struggle with a specific npm task.
In the Build process, after the first five tasks execute, I use an npm task with a custom command. This command executes webpack script defined in my package.json
npm run prod
"prod": "webpack --env.NODE_ENV=production --config webpack.config.js --progress"
When this task runs, it errors with the following message
Error: Npm failed with return code: 1
Thoughts? Suggestions? This is trying me a little insane, I'm sure there's a simple solution :)
Replace npm run prod to run prod in command and arguments box.