Karma/Jasmine – cannot start testing with new Angular 5 project (due tot index.d.ts errors) - karma-jasmine

When starting the test with ‘ng test’, the Chrome browser won’t start. I get this weird message.
karma jasmine ERROR in node_modules/#types/jasmine/index.d.ts(138,47): error TS1005: ';' expected.
My Angular version is 5.2 with the CLI 1.7.4.

The browser won’t start if you have errors – that’s what you saw.
Solution 1 – for solving the symptom:
I had the same issue. It may help when you update the typescript and jasmine types like so:
$ npm install --save-dev typescript#2.7
$ npm install --save-dev #types/jasmine#2.8.4
Solution 2 – more fundamental:
1 – Create a new Angular 5 project. Verify that testing is possible: ‘$ ng test’.
2 – Check the mismatch in versions in your package.json file. Correct these versions of your project according to the new sample project you just created. Do this with ‘npm install --save (or --save-dev)' of the packages. That way you will update the package.json file.
Success!

Related

ng-zorro Error: Module not found when trying to run project

I'm using ng-zorro v14.1.1 for my angular 14.2.7. But when I try to run my angular application, I got errors when building the project looking for modules from ng-zorro and identifying it as not found even though the files existed in the project.
Here's the full view of the error:
Additional detail of the project:
Angular Electron project
Angular 14.2.7
Electron 21.2.0
Thanks in advance for helping!
I tried removing node-modules and re-install ng-zorro-antd using ng add ng-zorro-antd, and even npm install ng-zorro-antd if it makes a difference but to no avail, I'm still having the issue. Thus, can't run the project.
I have solved my problem. What I did was to install the modules that are mentioned in the error:
I ran the commands:
npm i d3-zoom --> this command gives you hint on what to do next when you're trying to run the project after the installation is finished, and it instructed me to run the next command below:
npm i --save-dev #types/d3-zoom
npm i dagre-compound
npm i d3-shape

npm install cypress vs npm install cypress --save-dev

Iam new to cypress wanted to know what is difference between npm install cypress vs npm install cypress --save-dev I googled but not finding any answers
The difference between these two, is that devDependencies are modules which are only required during development, while dependencies are modules which are also required at runtime. src
Modules like Mochajs, cypress, jsdoc, etc are devDependencies, because they are useful just in develop Env and in Production Env We don't need them.
There are at least 2 different envs while developing, somewhere you develop and code and do some tests on your code(develop Env) and somewhere you deliver your product to your customer, which means you have tested your code completely and there is no need to run tests again(product).
You need some modules like cypress and mocha just for testing. In product env you don't need to test the product again. So you don't install extra modules!
So you need something like devDependencies in package manager to handle it for you.
With npm install cypress, you are just installing cypress. with npm install --save-dev you are installing it as a dev dependency.
With the command npm install cypress you are installing the latest version of cypress in your system and you have to give this command through vs code terminal.

npx from command line does not find imports?

I'm trying to run a simple hello.ts script from command line. This works if the script has no dependencies:
npx ts-node hello.ts
But as soon as I start adding some dependencies...
import _ from 'lodash';
console.log('hello');
It fails:
Cannot find module 'lodash' or its corresponding type declarations.
It keeps failing even if I install the dependencies globally. So how do I tell npx (or ts-node for that matter) to consider globally installed dependencies?
Update
Using Node 16.9.1 (upgraded via Version Lens). The error seems to have disappeared after uninstalling/reinstalling the imported libraries a few times.
If you're using npm >=1.0, you can use npm link to create a local link to a package already installed globally. (Caveat: The OS must support symlinks.)
IE: npm install -g lodash && npm link lodash
However, this doesn't come without its problems.
npm link is a development tool. It's awesome for managing packages on your local development box. But deploying with npm link is basically asking for problems, since it makes it super easy to update things without realizing it.
As an alternative, you can install the packages locally as well as globally.
For additional information, see:
https://nodejs.org/en/blog/npm/npm-1-0-link/
https://nodejs.org/en/blog/npm/npm-1-0-global-vs-local-installation/
Are you using the n package by any chance? I used n to change from a newer version of node (16.2.0) to an older version of node (12.13.0), ran npm i and npx failed with a different error.
Using n to change back to 16.2.0 seems to have resolved the issue so I'm thinking perhaps it was an issue with package-lock.json or such

Command invalid: run always ask to create a project

I have a project about 4 months and suddenly the aurelia's CLI commands are not working.
When I try to execute au run --watch I receive a message with options to create a new project under the path.
I have already tried to uninstall and reinstall the aurelia CLI, It's not work.
The last thing I have done was to execute a git clean -xdf
I think that could be something on my project. Someone could help me?
ANSWER
After some attempts I fixed the problem:
1) I reinstall Git and Node;
2) I have deleted all the files under the \AppData\Roaming\npm-cache path;
3) I have checked if the Git and Node were in the PATH of environment variables;
4) I run the npm install command;
Is aurelia-cli included in the devDependencies of the project and also installed globally?
First, install globally:
npm i -g aurelia-cli
Then, in the project directory, install & save to devDependencies:
npm i --save-dev aurelia-cli
You should then be able to run au in the project directory and see that the build and run commands are now available.
Note that you'll also need to install the necessary gulp dependencies required by the tasks in your project devDependencies.
EDIT: See aurelia/cli/issues/485 which confirms that installing aurelia-cli as a local dependency fixes this issue.

Travis not installing npm modules

I'm new to travis- I'm trying to get it to install my npm modules for my project and can't even get past that. "npm install" and "npm test" work fine on my computer (a mac). However, when I push my commits to travis it complains that:
Error: No compatible version found: ini#'^1.2.0'
Valid install targets:
npm ERR! ["1.0.0","1.0.1","1.0.2","1.0.3","1.0.4","1.0.5","1.1.0","1.2.0","1.2.1","1.3.0"]
Note that ini is not something I was originally including in my package.json, but it is depended on by something that I am using. I tried explicitly adding the 1.2.0 version of ini to my package.json but it still complains. I get similar complaints about other upstream dependencies.
Is there something about how travis is doing npm install that greatly differs from my local machine where it is working fine? Really stumped here.
Here's a link to my latest travis failed build: https://travis-ci.org/infomofo/chrome-angular-md-template/builds/35592993
This is due to the NPM version coming with Node.js 0.8. It doesn't support the ^ syntax for declaring dependecies.
You could either use Node.js instead:
node_js: 0.10
Or you could update npm, which would bring support for the dependency version:
before_install: npm update -q