突然我无法安装angular,我被npm install命令“ npm install -g @ angular / cli”卡住了。它永远停留在这种“检查可安装状态”上。
我的节点版本为8.11.3(是的,我已经尝试卸载节点并仔细检查以确保它确实已被卸载),这是我以前的版本,并且可以正常工作,我的npm -v给出了5.6.0
然后我运行angular命令安装angular,它似乎冻结或非常非常缓慢。
我一直在尝试将 Visual Studio 中的 Angular 项目更新为特定版本的 Angular。
我正在遵循本教程,并且做了一些不同的事情,因为通过本教程,我获得了现有的最新 Angular 版本,并且我特别想要 Angular 的版本 6。
为此,我运行了npm install -g @angular/cli@6.2.9而不是教程一 ( npm install -g npm-check-updates)
无论如何,我运行ncu -u命令后,就像教程一样。
最后我得到了版本 7 的 package.json,这不是我想要的。
我知道这ncu意味着npm-check-updates,并且熟悉-g它正在全球安装。到底是ncu -u做什么的,是更新吗?
那么它会忽略我的 6 版本并继续使用最后一个版本吗?
我应该在这里做什么?我想查看我的包 json 的更改,但针对 6 而不是 7,但此命令针对 7 执行此操作。
就像教程中的图像一样,您可以在命令行/PowerShell 中看到之前和之后的情况(正如教程所述,我在管理中使用了 PowerShell)。
我尝试使用这个 https://update.angular.io/
这仍然引导我使用版本 7...而不是我在下拉列表中选择的 6.1。看图片
我对使用笑话和酶进行单元测试仍然很陌生,\n我有一个数据测试 ID,我正在尝试使用它进行单元测试。然而,我收到一条错误消息,指出未找到 data-test-id。
\n我有以下内容
\nimport React from 'react';\nimport Adapter from 'enzyme-adapter-react-16';\nimport { configure, mount, shallow } from 'enzyme';\nimport { shallowToJson } from 'enzyme-to-json';\n\nimport ConfirmationModal from '../src/components/GlobalForm/ConfirmationModal/ConfirmationModal';\n\nconfigure({ adapter: new Adapter() });\n\ndescribe('ConfirmationModal', () => {\n it('should be defined', () => {\n expect(ConfirmationModal).toBeDefined();\n });\n\n it('should render correctly', () => {\n const tree = mount(<ConfirmationModal />);\n expect(shallowToJson(tree)).toMatchSnapshot();\n });\n\n it('should have a cancel button', () => {\n const wrapper = shallow(<ConfirmationModal />);\n const ConfirmationModalComponent = wrapper.find("[data-test-id='cancel-submit-btn']");\n expect(ConfirmationModalComponent.length).toBe(1);\n });\n});\nRun Code Online (Sandbox Code Playgroud)\n甚至我的快照测试也显示我有这个 data-test-id
\nexports[`ConfirmationModal …Run Code Online (Sandbox Code Playgroud) 我是角度6的新手,它是导航/路线选择,如果听起来很抱歉,对不起。
我试图使用一个具有导航到登录页面的功能的按钮,但我不断收到此错误:
“错误:未捕获(承诺):错误:无法匹配任何路由。URL段:'登录'错误:无法匹配任何路由。URL段:在ApplyRedirects.push ../ node_modules / @ angular / router / fesm5上的'login' /router.js.ApplyRedirects.noMatchError“
我的html是:
<button ion-button (click) = "openLogin()" >Efetuar login</button>
Run Code Online (Sandbox Code Playgroud)
我的路由器是:
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { LoginComponent } from './login/login.component';
const routes: Routes = [
{
path: 'login',
outlet: 'login',
component: LoginComponent
},
{ path: '', loadChildren: './tabs/tabs.module#TabsPageModule' }
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule {}
Run Code Online (Sandbox Code Playgroud)
我一直在研究此问题,只要路径与路由器中定义的路径相对应,就不会有任何问题,但我会不断遇到此错误。
我正在尝试创建一个模拟服务,但我收到一个错误“类型有一个私有属性的单独声明”,对我来说,声明似乎是平等的,但没有不同,但它说不在错误中。我正在一个注入了服务的组件中进行此测试!!!是的,我想在这里用模拟测试来测试它。
我的模拟服务代码:
class MockDataservice {
result: any;
constructor(private http: HttpClient){
sendCodeToServer() {
return this.result;
}
}
describe('HomePage', () =>
...
{
...
beforeEach(() => {
...
service = new MockDataservice(http);
component = new HomePage(platform, service, splash, statusbar, barcode, alert, http, loading, router);
Run Code Online (Sandbox Code Playgroud)
原服务:
export class DataStorageService {
result: any;
constructor(private http: HttpClient) {
}
sendToServer(data) {
const headers = new HttpHeaders().set('Content-Type', 'application/json');
return new Promise((resolve, reject) => {
this.http.post(endpoindURL, data, { headers: headers })
.toPromise().then((data) => {
resolve(data);
}).catch((err) => …Run Code Online (Sandbox Code Playgroud) angular ×4
unit-testing ×2
enzyme ×1
install ×1
javascript ×1
jestjs ×1
node.js ×1
npm ×1
reactjs ×1
routing ×1