I am using jhipster 4.13.0. Anything is ok until I create production package:
./mvnw -Pprod package
It is always failed in karma test. How can I skip the karma test, because I don't need it?
Try running this command in your terminal:
./mvnw -Pprod package -DskipTests
Edit your package.json and remove call to karma from "test": "yarn run lint && karma start src/test/javascript/karma.conf.js"
Related
I have a package installed in node using
npm i mypackage --save-dev
and it works fine on the command line with
npx mypackage --options
but when I want to have it in the package.json files scripts section it it fails. I tried
"scripts": {
"mystuff": "mypackage --options",
"mystuffnpm": "npm run mypackage --options",
"mystuffnpx": "npx mypackage --options"
}
but nothing works. What is the right way to get it in the scripts section running?
After integrating any package without command try "npx run".It will
install the missing packages in node modules.
Make sure you are running the command in the specific directory.
Try "npm init -y" to make new package.json file and then install the
packages.
On an inherited project I have, I am trying to get the build command to build a version other than Production.
I have attempted to change the alias in the script section in package.json to pass in extra variables such as --dev and --configuration=dev to no avail.
The project has these json data files:
env.dev
env.development
env.production
with the package.json has this build alias build:dev which I run npm run build:dev:
"scripts": {
"start": "NODE_ENV=dev && react-scripts start",
…
"build:dev": "npm run build --dev --configuration=dev && react-scripts build"
}
This works and builds, but for production only which I verify when I view the resultant files.
If I remove the file env.production from the directory and run the build command, it fails with:
Creating an optimized production build...
Failed to compile.
Module not found: Error: Can't resolve 'polyfills' in 'C:\Work\MyProj\WebSiteName\src'
which just informs me that it can alias polyfills found in the env.production file for the location NODE_PATH=src/.
Thoughts?
you need to set the env. variable like you do in "start" before calling the build command.
"build:dev": "NODE_ENV=dev npm run build --dev --configuration=dev && react-scripts build"
I have a problem with my Angular project. Especially on the build of the project.
When I build my Angular poject with
ng build
it creates the dist-folder with the correct build. When I use the following command:
ng build --prod
it creates the production build (correct)
When I use NPM (used by build server) I use this:
run build
But I want the production build. Whatever I do, it doesn't work locally or on the buildserver. I used these:
npm run build --prod
npm run build --target=production
npm run build --environment=prod
npm run build --environment=production
npm run build --env=production
npm run build --env=prod
npm run build *projectname* --environment=production
npm run build *projectname* --env=production
npm run build *projectname* production
And probably a lot more. It just does not build the production!
I have a environment.prod.ts (production = true). It is set in the Angular.json. I have no clue what I am doing wrong.
You could also use -- to separate the params passed to npm command itself and params passed to your script.
So the correct syntax for your case would be:
npm run build -- --prod
npm run build should have the script in the package.json
have a look there and maybe add the line in the scripts
{
...
scripts: {
"build": "ng build --prod"
},
...
}
this should do the trick
What you can do is update the build script in the package.json as
scripts:{
"build": "npm run ng build --",
"ng": "ng"
}
-- allows you to pass arguments to a script.
Then you can pass the arguments to ng build like ng build --prod
Try this if your environment is production:
npm run build -- --configuration=production
or this if it's prod:
npm run build -- --configuration=prod
If you don't specify the "configuration" parameter name you may see this error:
npm run build -- --prod
Error: Unknown argument: prod
npm run build -- --production
Error: Unknown argument: production
aiming at using Travis-ci for continuous integration , I am processing in my settings... however I get stuck now with this error upon executing package.json scrip test
cross-env BABEL_ENV=test karma start test/unit/karma.conf.js --single-run --browsers ChromeHeadless
sh: 1: cross-env: not found
however, the cross-env package is installed in the dv dependencies
"cross-env": "^5.0.5",
here is the log : Travis build log
Error in travis.yml
should be
install:
- yarn
script:
- yarn test
and not
install:
- yarn test
!! my mistake
I am using Travis CI to test and build my project and as part of it I want travis to run grunt build i have tried the following but have had no luck.
script: "grunt build"
script: "./node_modules/grunt build"
script: "./node_modules/grunt/grunt build"
script: "./node_modules/grunt/grunt.js build"
Have you made sure to install grunt-cli globally on your Travis node?
My Travis CI config looks like:
language: node_js
node_js:
- "0.8"
before_install: npm install -g grunt-cli
install: npm install
before_script: grunt build
And my package.json:
{
...
"scripts": {
"test": "grunt test"
},
...
}
I will explain the flow of steps that Travis will execute:
The first step to be executed is the before_install. My only prerequisite (besides node.js) is grunt-cli so I use this step to install it.
Next is the install step, in my case this will simply install my npm modules
The before script is then executed, running grunt build
Lastly Travis will look for scripts in the package.json, there I indicated the test step should run grunt test
I'd like to note that this is my own opinion on how to configure Travis. I'm certainly not inclining you should use exactly the same approach.
You likely miss in your travis.yml file:
before_script:
- npm install -g grunt-cli
Then "grunt whatever" should execute ok (assuming you do require grunt in your devDependencies in your package.json).
(see http://www.mattgoldspink.co.uk/2013/02/10/using-travis-ci-with-grunt-0-4-x/)
Make sure that you have grunt as part of your devDependencies. Here is a sample file: https://github.com/fraxedas/raspi-cloud/blob/master/package.json
"devDependencies": {
"grunt": "^0.4.5",
"grunt-contrib-jshint": "^0.11.2",
"grunt-contrib-watch": "^0.6.1"
}
Travis-ci will install grunt on the install step:
npm install
...
grunt#0.4.5 node_modules/grunt
...
In my case I wanted to run jshint with grunt.
Here is my travis.yml file: https://github.com/fraxedas/raspi-cloud/blob/master/.travis.yml
To integrate grunt all I needed was:
before_script: grunt jshint
You can change jshint by another command.
My .travis.yml looks like this:
It runs much faster than npm as NodeJSpackage manager, I'm using Yarnon this example. It installs yarn, grunt cli, rubyand sass.
Hopefully it helps.
language: node_js
node_js:
- "7.1.0"
before_install:
- npm install -g yarn
- yarn add global ruby
- gem install sass
install:
- yarn add global sass
- yarn add global grunt-cli
- yarn add yarn install
before_script: grunt