微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在Reactjs应用中,npm run build给出错误

如何解决在Reactjs应用中,npm run build给出错误

当我尝试在我的reactjs应用程序中运行构建脚本时,它给了我一个错误[BABEL] nodule模块。/parse。它还显示了与webpack相关的错误,因此我重新安装了节点模块并单独安装了webpack模块,但是现在当我尝试运行构建脚本时,出现以下说明和终端错误,我逐步尝试了所有说明,但对我没有任何帮助


    nishant@nishant-H81M-S:~/MEGAsync/dev_projects/root/frontend_client$ npm run build
    
    > frontend_client@1.0.0 build /home/nishant/MEGAsync/dev_projects/root/frontend_client
    > react-scripts build
    
    
    There might be a problem with the project dependency tree.
    It is likely not a bug in Create React App,but something you need to fix locally.
    
    The react-scripts package provided by Create React App requires a dependency:
    
      "webpack": "4.42.0"
    
    Don't try to install it manually: your package manager does it automatically.
    However,a different version of webpack was detected higher up in the tree:
    
      /home/nishant/MEGAsync/dev_projects/root/node_modules/webpack (version: 4.44.1) 
    
    Manually installing incompatible versions is kNown to cause hard-to-debug issues.
    
    If you would prefer to ignore this check,add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
    That will permanently disable this message but you might encounter other issues.
    
    To fix the dependency tree,try following the steps below in the exact order:
    
      1. Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder.
      2. Delete node_modules in your project folder.
      3. Remove "webpack" from dependencies and/or devDependencies in the package.json file in your project folder.
      4. Run npm install or yarn,depending on the package manager you use.
    
    In most cases,this should be enough to fix the problem.
    If this has not helped,there are a few other things you can try:
    
      5. If you used npm,install yarn (http://yarnpkg.com/) and repeat the above steps with it instead.
         This may help because npm has kNown issues with package hoisting which may get resolved in future versions.
    
      6. Check if /home/nishant/MEGAsync/dev_projects/root/node_modules/webpack is outside your project directory.
         For example,you might have accidentally installed something in your home folder.
    
      7. Try running npm ls webpack in your project folder.
         This will tell you which other package (apart from the expected react-scripts) installed webpack.
    
    If nothing else helps,add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
    That would permanently disable this preflight check in case you want to proceed anyway.
    
    P.S. We kNow this message is long but please read the steps above :-) We hope you find them helpful!
    
    npm ERR! code ELIFECYCLE
    npm ERR! errno 1
    npm ERR! frontend_client@1.0.0 build: `react-scripts build`
    npm ERR! Exit status 1
    npm ERR! 
    npm ERR! Failed at the frontend_client@1.0.0 build script.
    npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
    
    npm ERR! A complete log of this run can be found in:
    npm ERR!     /home/nishant/.npm/_logs/2020-09-17T16_30_20_732Z-debug.log

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。