小编bie*_*ier的帖子

ERROR in找不到模块'node-sass'

配置:macOS High Sierra,版本10.13.2,节点:v8.1.2 npm:5.0.3当我在我的angularjs项目中运行npm start时出现此错误:

ERROR in Cannot find module 'node-sass'
Run Code Online (Sandbox Code Playgroud)

在此之后我运行:

npm i node-sass
Run Code Online (Sandbox Code Playgroud)

现在我收到这个错误:

gyp: No Xcode or CLT version detected!
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
Run Code Online (Sandbox Code Playgroud)

为什么npm不会安装node-sass?我该如何安装node-sass?

node.js npm angularjs macos-high-sierra

118
推荐指数
10
解决办法
17万
查看次数

在git bash中设置一个环境变量

当我从windows gitbash命令行:

set $HOME = c
Run Code Online (Sandbox Code Playgroud)

并做:

echo $HOME
Run Code Online (Sandbox Code Playgroud)

它没有设置它c?如何更改/设置环境变量的值?

git git-bash

55
推荐指数
3
解决办法
9万
查看次数

如何在react链接组件上使用onClick事件?

我正在使用reactjs路由器的链接组件,我无法使onClickevent正常工作.这是代码:

<Link to={this.props.myroute} onClick='hello()'>Here</Link>
Run Code Online (Sandbox Code Playgroud)

这是通过这种方式或其他方式实现的吗?

reactjs react-router react-redux

52
推荐指数
4
解决办法
10万
查看次数

如何对反应组分的方法进行单元测试?

我正在尝试对我的reactjs组件进行单元测试:

import React from 'react';
import Modal from 'react-modal';
import store from '../../../store'
import lodash from 'lodash'

export class AddToOrder extends React.Component {
  constructor(props) {
    super(props);
    this.state = {checked: false}
    //debugger
  }
  checkBoxChecked() {
    return true
  }
  render() {
    console.log('testing=this.props.id',this.props.id )
    return (
      <div className="order">
        <label>
          <input
            id={this.props.parent}
            checked={this.checkBoxChecked()}
            onChange={this.addToOrder.bind(this, this.props)}
            type="checkbox"/>
          Add to order
        </label>
      </div>
    )
  }
}

export default AddToOrder;
Run Code Online (Sandbox Code Playgroud)

刚开始我已经在努力断言checkBoxChecked方法:

import React from 'react-native';
import {shallow} from 'enzyme';
import {AddToOrder} from '../app/components/buttons/addtoorder/addtoorder';
import {expect} from 'chai'; …
Run Code Online (Sandbox Code Playgroud)

unit-testing chai reactjs enzyme

49
推荐指数
2
解决办法
4万
查看次数

为什么我不断收到Delete'cr'[prettier / prettier]?

我在Prettier 1.7.2和Eslint 1.7.0中使用vscode。每换行后,我得到:

[eslint] Delete 'cr' [prettier/prettier]
Run Code Online (Sandbox Code Playgroud)

这是.eslintrc.json:

{
"extends": ["airbnb", "plugin:prettier/recommended"],
"env": {
"jest": true,
"browser": true
},
"rules": {
"import/no-extraneous-dependencies": "off",
"import/prefer-default-export": "off",
"no-confusing-arrow": "off",
"linebreak-style": "off",
"arrow-parens": ["error", "as-needed"],
"comma-dangle": [
"error",
{
"arrays": "always-multiline",
"objects": "always-multiline",
"imports": "always-multiline",
"exports": "always-multiline",
"functions": "ignore"
}
],
"no-plusplus": "off"
},
"parser": "babel-eslint",
"plugins": ["react"],
"globals": {
"browser": true,
"$": true,
"before": true,
"document": true
}
}
Run Code Online (Sandbox Code Playgroud)

.prettierrc

{
    "printWidth": 80,
    "tabWidth": 2,
    "semi": true,
    "singleQuote": true,
    "trailingComma": "es5",
    "bracketSpacing": …
Run Code Online (Sandbox Code Playgroud)

reactjs visual-studio-code prettier eslintrc

26
推荐指数
25
解决办法
1万
查看次数

如何通过redux中的api获取数据?

我是reactjs/redux的初学者,找不到一个简单易用的如何使用api调用来检索redux应用程序中的数据的示例.我想你可以使用jquery ajax调用,但有可能有更好的选择吗?

reactjs react-redux

25
推荐指数
2
解决办法
4万
查看次数

如何解决'错误TS2351:不能对类型缺少调用或构造签名的表达式使用'new'.'?

我将一个名为Auth.js的.js文件(因此不是.ts文件)导入到reactjs和typescript应用程序中,所以在我的组件中我有这个:

import * as Auth from '../Auth/Auth';
..
const auth = new Auth();
Run Code Online (Sandbox Code Playgroud)

这是我的Auth.js的一部分:

    export default class Auth {
        auth0 = new auth0.WebAuth({
            domain: AUTH_CONFIG.domain,
            clientID: AUTH_CONFIG.clientId,
            redirectUri: AUTH_CONFIG.callbackUrl,
            audience: `https://${AUTH_CONFIG.domain}/userinfo`,
            responseType: 'token id_token',
            scope: 'openid'
        });

        constructor() {
            this.login = this.login.bind(this);
            this.logout = this.logout.bind(this);
            this.handleAuthentication = this.handleAuthentication.bind(this);
            this.isAuthenticated = this.isAuthenticated.bind(this);
        }
..
Run Code Online (Sandbox Code Playgroud)

当我运行webpack时,我收到以下错误消息:

ERROR in ./src/containers/main.tsx
(16,14): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
Run Code Online (Sandbox Code Playgroud)

如何解决此TS错误?

javascript typescript reactjs

18
推荐指数
1
解决办法
2万
查看次数

如何在reducer中切换属性?

我在reactjs/redux中使用这个reducer构建了一个购物车应用程序:

const initialState = {
    items: [],
    cartOpen: false,
    total: 0
}

const Cart = (state = initialState, action) => {
    switch (action.type) {
        case 'ADD_TO_CART':
            let newstate = [...state, action.payload];
            var newTotal = 0;
            newstate.forEach(it => {
                newTotal += it.item.price;
            });
            newstate.total = newTotal;
            newstate.cartOpen =true
            return newstate;

        case 'TOGGLE_CART':
            debugger;
            return !state.cartOpen;

        default:
            return state
    }
}

export default Cart;
Run Code Online (Sandbox Code Playgroud)

我试图设置购物车的状态即打开,但是当我检查日志时,购物车属性是否更新而不是cartOpen属性?

reactjs react-redux

13
推荐指数
2
解决办法
1万
查看次数

包rxjs@5.0.0-beta.6不满足其兄弟姐妹的peerDependencies要求?

我想在我的angular 2应用程序中安装@ ngrx/store模块.我正在使用npm install并收到以下错误:

npm ERR! peerinvalid The package rxjs@5.0.0-beta.6 does not satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer @angular/core@2.0.0-rc.0 wants rxjs@5.0.0-beta.6
npm ERR! peerinvalid Peer @angular/http@2.0.0-rc.0 wants rxjs@5.0.0-beta.6
npm ERR! peerinvalid Peer angular2@2.0.0-beta.16 wants rxjs@5.0.0-beta.2
npm ERR! peerinvalid Peer @ngrx/store@1.5.0 wants rxjs@5.0.0-beta.6
Run Code Online (Sandbox Code Playgroud)

这是否意味着我必须升级我的angular2模块,因为它需要更低版本的rxjs@5.0.0-beta.2?

npm ngrx angular

12
推荐指数
1
解决办法
6062
查看次数

如何使用Nightwatch滚动到元素?

我正在使用夜视来测试我的应用程序.其中一个测试失败,因为它无法滚动到我怀疑它正在测试的元素.问题我需要滚动还是有其他方法可以做到?这是我正在测试的元素:

 return this.waitForElementVisible('#myElement', 4000) //wait for it to be visible
       .assert.visible('#myElement')
       .click('#myElement')
Run Code Online (Sandbox Code Playgroud)

该元素位于页面的顶部,但testrunner在页面上向下滚动了一下,并且在屏幕截图中不可见.如果需要滚动到此元素,我该怎么办?或:我如何测试这个元素?

javascript selenium-webdriver nightwatch.js

12
推荐指数
3
解决办法
1万
查看次数