小编Lit*_*ore的帖子

React 项目中的 Tailwind - 在安装过程中出现“无法找到模块‘autoprefixer’”错误

我正在关注https://tailwindcss.com/docs/guides/create-react-app上关于在 React 项目中设置 Tailwind 的文档。我一直在按照这些步骤操作,但是当我到达应该运行npx tailwindcss init以生成tailwind.config.js文件的部分时,出现以下错误:

Cannot find module 'autoprefixer'
Require stack:
- C:\Users\[user]\AppData\Roaming\npm-cache\_npx\16096\node_modules\tailwindcss\lib\cli\commands\build.js
- C:\Users\[user]\AppData\Roaming\npm-cache\_npx\16096\node_modules\tailwindcss\lib\cli\commands\index.js
- C:\Users\[user]\AppData\Roaming\npm-cache\_npx\16096\node_modules\tailwindcss\lib\cli\main.js
- C:\Users\[user]\AppData\Roaming\npm-cache\_npx\16096\node_modules\tailwindcss\lib\cli.js
Run Code Online (Sandbox Code Playgroud)

我检查autoprefixer了我的node_modules文件夹中是否有并尝试重新安装它,但我遇到了同样的错误。在我的package.json,我有以下内容:

...
  "scripts": {
    "start": "craco start",
    "build": "craco build",
    "test": "craco test",
    "eject": "react-scripts eject"
  },
...
Run Code Online (Sandbox Code Playgroud)

根据文档。我的craco.config.js文件如下:

module.exports = {
  style: {
    postcss: {
      plugins: [
        require('tailwindcss'),
        require('autoprefixer'),
      ],
    },
  },
}
Run Code Online (Sandbox Code Playgroud)

再次,根据文档。我也试过重新安装@craco/craco软件包无济于事,所以在这一点上我被卡住了。任何帮助,将不胜感激。

javascript reactjs create-react-app npx tailwind-css

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

Socket.IO 尝试通过 https:// 而不是 wss:// 进行连接并收到 CORS 错误

我正在从JavaScript's原始WebSocketAPI切换到Socket.IO有关cryptocurrency价格的实时数据。在使用常规时,WebSocket我没有问题连接Kraken和获取我需要的数据。但是,在尝试与 连接时Socket.IO,出现CORS错误。

CORS 政策已阻止在“ https://ws.kraken.com/socket.io/?EIO=3&transport=polling&t=Mxg8_5_ ”处访问 XMLHttpRequest :不存在“Access-Control-Allow-Origin”标头在请求的资源上。

在 Chrome 开发工具网络选项卡中,我收到Invalid request来自Kraken. 我假设Socket.IO在尝试建立websocket连接时尝试发送某种预检请求,但由于Kraken's CORShttp 请求的策略而失败。有没有办法完全绕过这种XMLHttpRequest尝试并立即尝试websocket连接,因为常规WebSocketAPI 在建立此连接时没有问题并且似乎没有发送预检请求?这是香草和Socket.IO插座:

// vanilla websocket
const vanillaWS = new WebSocket('wss://ws.kraken.com');
vanillaWS.onopen = () => {
  console.log('vanilla websocket opened');
}
vanillaWS.onmessage = (message) => {
  console.log(message.data);
}

// socket.io websocket
const ioSocket = …
Run Code Online (Sandbox Code Playgroud)

javascript websocket cors socket.io

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

无法从 React Native 的 Material Top Bar Navigator 中删除 boxShadow

我正在使用 React Native 导航包中的顶部选项卡导航,该导航包是通过该createMaterialTopTabNavigator()函数创建的。默认情况下,标签栏上有一个框阴影,我想禁用它。这是我的标签屏幕配置代码:

const TabScreen = createMaterialTopTabNavigator(
  {
    "Test one": { screen: TestScreen1 },
    "Test two": { screen: TestScreen2 },
    "Test three": { screen: TestScreen3 },
  },
  {
    tabBarPosition: 'top',
    swipeEnabled: true,
    animationEnabled: true,
    tabBarOptions: {
      upperCaseLabel: false,
      scrollEnabled: true,
      activeTintColor: '#000',
      inactiveTintColor: 'rgb(180, 180, 180)',
      pressColor: 'orange',
      style: {
        boxShadow: 'none',
        backgroundColor: '#fff',
        numberOfLines: 1,
      },
      tabStyle: {
        //
      },
      labelStyle: {
        fontSize: 16,
        textAlign: 'center',
      },
      indicatorStyle: {
        borderBottomColor: 'orange',
        borderBottomWidth: 4,
      },
    },
  } …
Run Code Online (Sandbox Code Playgroud)

react-native react-navigation

2
推荐指数
2
解决办法
1390
查看次数