Skip to content

Cannot read property 'exclude' of undefined #145

Closed
@zhaoyu69

Description

@zhaoyu69

use ant-design in create-react-app,err in react-app-rewire-less,details that the flowing items show.

1.package.json

package

2.config-override

config-override

3.npm start err

exclude

4.delete some code related to less,it works but...no style!

deleteitem

nocss

5.update config-override.js type:true ===> type:'css',it works for css but not for less.

noless

how to resolve it to make my project works well ?

Activity

likun7981

likun7981 commented on Nov 27, 2017

@likun7981
Collaborator

I try it with your version, it is not wrong.
Can you provide your demo code?

zhaoyu69

zhaoyu69 commented on Nov 27, 2017

@zhaoyu69
Author

https://github.com/zhaoyu69/antd-spa
This is my github address.
It contains serialport, so you have to config
from https://github.com/nodejs/node-gyp.

Thanks!

zhaoyu69

zhaoyu69 commented on Nov 27, 2017

@zhaoyu69
Author

Or you can commented out some part of component.
I just want to see the less style to work.

likun7981

likun7981 commented on Nov 28, 2017

@likun7981
Collaborator

I test your demo code and add rewire-less with options, it is not wrong.

zhaoyu69

zhaoyu69 commented on Nov 28, 2017

@zhaoyu69
Author

I try again with another PC , also not work. can you give me some advice?

dawnmist

dawnmist commented on Nov 28, 2017

@dawnmist
Collaborator

I've also just tried your git repo (master). Before I could test, I made the following changes:

  1. Upgraded react-app-rewire-less to 2.1.0 first - the repo is pointing to ^2.0.9 in the package-lock.json file rather than the ^2.1.0 in your report.
  2. Added the less rewire back into the config-overrides.js file.
  3. Fixed the case of the less filename imported in the acq1 component - I'm on linux, so paths are case-sensitive. The ACQ1.jsx file was importing the acq1.less file in upper-case while the filename for the less file was lower-case.

Having made those 3 changes to the master version of your repository, both yarn start and npm run start were able to run the app and show the login screen screenshot.

Are you working on Windows? I'm wondering whether the test for finding the file-loader config rule inside the less rewire is failing due to the difference in Windows vs Linux path separators.

likun7981

likun7981 commented on Nov 29, 2017

@likun7981
Collaborator

The path separators is use path.sep , This can not be a path separators question. you can clear your npm cache and delete package-lock.json, try again install.

dawnmist

dawnmist commented on Nov 29, 2017

@dawnmist
Collaborator

I saw that we were using path.sep - what I wasn't sure about was whether the require.resolve('file-loader') that react-scripts use returns the path in Windows or Posix format when used on a Windows system. Since the actual failure line points to the line where we try to alter the file-loader rule, it stands to reason that there is something odd causing it to be unable to find that rule on some computers. Since the example repo also had an issue where it was importing a local file with the wrong case ('ACQ1.less' instead of 'acq1.less'), it indicated that @zhaoyu69 was possibly working on an OS where filenames were not case-sensitive. Hence my question about using Windows and why I was suspicious that there might have been a mismatch between the file-loader definition from react-scripts and our searching for it using path.sep.

zhaoyu69

zhaoyu69 commented on Dec 1, 2017

@zhaoyu69
Author

I Follow your steps,try again but failed too,I'm going to redo my system then try again.

dawnmist

dawnmist commented on Dec 1, 2017

@dawnmist
Collaborator

@zhaoyu69 If it is still failing after redoing your system, could you please alter your config-overrides.js file to add the following 3 lines after the call to injectBabelPlugin to get some logging output then post the output:

module.exports = function override(config, env) {
    config = injectBabelPlugin(['import', { libraryName: 'antd', style: true }], config);
    console.log(`Rules: ${JSON.stringify(config.module.rules, (key, value) => { return (value && value.constructor === RegExp) ? value.toString() : value}, 2)}`);
    console.log(`PathSep: ${path.sep}`);
    throw new Error('Escape here...');

Note: This will not fix anything, its purpose is to generate some debugging information so that we can try to see what the react-app-rewire-less plugin is being given as input. The throw new Error just makes sure that the script doesn't continue any further. All 3 new lines should be removed again after generating the logging text.

zhaoyu69

zhaoyu69 commented on Dec 4, 2017

@zhaoyu69
Author

I added a word : const { path } = require('path');
but throw error : TypeError: Cannot read property 'sep' of undefined
How to deal with it?

dawnmist

dawnmist commented on Dec 4, 2017

@dawnmist
Collaborator

Sorry - I forgot that bit.

Use const path = require('path'); - no braces.

7 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @dawnmist@likun7981@zhaoyu69

        Issue actions

          Cannot read property 'exclude' of undefined · Issue #145 · timarney/react-app-rewired