即使在删除 node_modules 和 npm install 后安装新包时也无法修复编译错误

如何解决即使在删除 node_modules 和 npm install 后安装新包时也无法修复编译错误

我像下面提到的那样安装了 react-select-virtualized here

tan@MXL9492NNH MINGW64 /c/tan/projectlens/testing related folders/for_npm_react_virtualized_testing/projectexplorer (develop)
$ npm install --save react-select-virtualized
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated core-js@2.6.12: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please,upgrade your dependencies to the actual version of core-js@3.
npm WARN deprecated fsevents@1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
npm WARN deprecated chokidar@2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
npm WARN rm not removing C:\tan\projectlens\testing related folders\for_npm_react_virtualized_testing\projectexplorer\node_modules\.bin\uglifyjs.cmd as it wasn't installed by C:\tan\projectlens\testing related folders\for_npm_react_virtualized_testing\projectexplorer\node_modules\uglify-js
npm WARN rm not removing C:\tan\projectlens\testing related folders\for_npm_react_virtualized_testing\projectexplorer\node_modules\.bin\uglifyjs as it wasn't installed by C:\tan\projectlens\testing related folders\for_npm_react_virtualized_testing\projectexplorer\node_modules\uglify-js
npm WARN rm not removing C:\tan\projectlens\testing related folders\for_npm_react_virtualized_testing\projectexplorer\node_modules\.bin\semver.cmd as it wasn't installed by C:\tan\projectlens\testing related folders\for_npm_react_virtualized_testing\projectexplorer\node_modules\semver
npm WARN rm not removing C:\tan\projectlens\testing related folders\for_npm_react_virtualized_testing\projectexplorer\node_modules\.bin\semver as it wasn't installed by C:\tan\projectlens\testing related folders\for_npm_react_virtualized_testing\projectexplorer\node_modules\semver
npm WARN rm not removing C:\tan\projectlens\testing related folders\for_npm_react_virtualized_testing\projectexplorer\node_modules\.bin\json5.cmd as it wasn't installed by C:\tan\projectlens\testing related folders\for_npm_react_virtualized_testing\projectexplorer\node_modules\json5
npm WARN rm not removing C:\tan\projectlens\testing related folders\for_npm_react_virtualized_testing\projectexplorer\node_modules\.bin\json5 as it wasn't installed by C:\tan\projectlens\testing related folders\for_npm_react_virtualized_testing\projectexplorer\node_modules\json5

> @fortawesome/fontawesome-common-types@0.2.34 postinstall C:\tan\projectlens\testing related folders\for_npm_react_virtualized_testing\projectexplorer\node_modules\@fortawesome\fontawesome-common-types
> node attribution.js

Font Awesome Free 0.2.34 by @fontawesome - https://fontawesome.com
License - https://fontawesome.com/license/free (Icons: CC BY 4.0,Fonts: SIL OFL 1.1,Code: MIT License)


> core-js@2.6.12 postinstall C:\tan\projectlens\testing related folders\for_npm_react_virtualized_testing\projectexplorer\node_modules\core-js
> node -e "try{require('./postinstall')}catch(e){}"

Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!

The project needs your help! Please consider supporting of core-js on Open Collective or Patreon:
> https://opencollective.com/core-js
> https://www.patreon.com/zloirock

Also,the author of core-js ( https://github.com/zloirock ) is looking for a good job -)

npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.3.1 (node_modules\@babel\cli\node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.7 (node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.7 (node_modules\watchpack-chokidar2\node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.7 (node_modules\webpack-dev-server\node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"x64"})
npm WARN bootstrap@4.6.0 requires a peer of jquery@1.9.1 - 3 but none is installed. You must install peer dependencies yourself.
npm WARN bootstrap@4.6.0 requires a peer of popper.js@^1.16.1 but none is installed. You must install peer dependencies yourself.
npm WARN primereact@4.2.2 requires a peer of classnames@^2.2.6 but none is installed. You must install peer dependencies yourself.
npm WARN react-select-virtualized@3.0.0 requires a peer of react@16.13.1 but none is installed. You must install peer dependencies yourself.
npm WARN react-select-virtualized@3.0.0 requires a peer of react-dom@16.13.1 but none is installed. You must install peer dependencies yourself.
npm WARN react-select-virtualized@3.0.0 requires a peer of react-select@4.1.0 but none is installed. You must install peer dependencies yourself.
npm WARN react-select-virtualized@3.0.0 requires a peer of react-virtualized@9.22.2 but none is installed. You must install peer dependencies yourself.
npm WARN ldapdemo@0.0.1 No repository field.

+ react-select-virtualized@3.0.0
added 101 packages from 83 contributors,removed 54 packages,updated 1057 packages and audited 1222 packages in 109.002s

53 packages are looking for funding
  run `npm fund` for details

found 3 vulnerabilities (1 moderate,2 high)
  run `npm audit fix` to fix them,or `npm audit` for details
  

当我这样启动我的应用程序时:

yarn run local ,它没有编译并显示以下错误:

i 「wdm」: Failed to compile.
Error from chokidar (C:\): Error: EBUSY: resource busy or locked,lstat 'C:\hiberfil.sys'
Error from chokidar (C:\): Error: EBUSY: resource busy or locked,lstat 'C:\pagefile.sys'
Error from chokidar (C:\): Error: EBUSY: resource busy or locked,lstat 'C:\swapfile.sys'  

所以我删除了 node_modules 文件夹,然后按照 this post 中的说明做了 npm install

编译成功。但是,当我将它包含在我的代码中时,如下所示:

import { Select as SecondSelect } from 'react-select-virtualized';  

它再次抛出相同的错误:

Child html-webpack-plugin for "index.html":
     1 asset
    Entrypoint undefined = index.html
       1 module
i 「wdm」: Failed to compile.
Error from chokidar (C:\): Error: EBUSY: resource busy or locked,lstat 'C:\swapfile.sys'

如何解决这个问题?

这是我的 package.json

{
  "name": "ldapdemo","version": "0.0.1","description": "Project Lens","main": "index.js","author": "Tan","license": "MIT","scripts": {
    "local": "webpack-dev-server --env.REACT_APP_ROUTER_BASE= --env.REACT_APP_USERNAME=tan --mode development --inline","dev": "webpack --env.REACT_APP_ROUTER_BASE= --env.REACT_APP_USERNAME=tan --mode development ./src/main/js/app.js --output ./src/main/resources/static/built/bundle.js","build": "webpack --mode production ./src/main/js/app.js ","webpack-prod": "webpack -p --progress --config=config/webpack.prod.js --mode production ./src/main/js/app.js"
  },"dependencies": {
    "@babel/plugin-proposal-throw-expressions": "^7.2.0","@emotion/core": "^10.0.27","@fortawesome/fontawesome-svg-core": "^1.2.27","@fortawesome/free-solid-svg-icons": "^5.12.1","@fortawesome/react-fontawesome": "^0.1.9","@material-ui/core": "^4.8.3","@material-ui/icons": "^4.5.1","@material-ui/lab": "^4.0.0-alpha.46","@types/react": "^16.4.2","@types/react-dom": "^16.4.2","@types/react-router-dom": "^4.3.4","@types/styled-jsx": "^2.2.8","awesome-typescript-loader": "^5.2.1","axios": "^0.18.0","babel-plugin-transform-class-properties": "^6.24.1","bootstrap": "^4.1.3","classnames": "^2.2.6","css-loader": "^1.0.0","csstype": "^2.6.8","formik": "^2.1.2","html-loader": "^0.5.5","html-webpack-plugin": "^3.2.0","jqwidgets-scripts": "^7.2.0","lodash": "^4.17.15","primeflex": "^1.1.1","primeicons": "^4.0.0","primereact": "4.2.2","react": "^16.4.2","react-autosuggest": "^9.4.2","react-bootstrap": "^1.0.0-beta.16","react-dom": "^16.4.2","react-filtered-multiselect": "^0.5.1","react-google-charts": "^3.0.15","react-iframe": "^1.8.0","react-json-view": "^1.19.1","react-memoize": "^1.0.1","react-minimal-pie-chart": "^8.0.1","react-router": "^4.3.1","react-router-dom": "^4.3.1","react-select-virtualized": "^3.0.0","react-spinners": "^0.8.0","react-transition-group": "^2.5.3","react-window": "^1.8.5","style-loader": "^0.23.0","styled-components": "^4.2.0","styled-jsx": "^3.2.4","ts-loader": "^6.0.4","typescript": "^3.5.3","webpack-dev-server": "^3.3.1","yup": "^0.27.0"
  },"devDependencies": {
    "@babel/cli": "^7.0.0","@babel/core": "^7.0.0","@babel/preset-env": "^7.0.0","@babel/preset-react": "^7.0.0","@babel/preset-typescript": "^7.3.3","@fortawesome/fontawesome-free": "^5.3.1","babel-loader": "^8.0.6","clean-webpack-plugin": "^2.0.1","copy-webpack-plugin": "^5.0.3","file-loader": "^2.0.0","formsy-react": "^1.1.5","mini-css-extract-plugin": "^0.6.0","optimize-css-assets-webpack-plugin": "^5.0.1","react-hot-loader": "^4.8.4","uglifyjs-webpack-plugin": "^2.1.2","webpack": "^4.30.0","webpack-cli": "^3.3.1","webpack-merge": "^4.2.1"
  }
}

添加了 webpack.config.js 以帮助解决上述问题:

const webpack = require('webpack')
const path = require('path');
const glob = require("glob");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const HtmlWebPackPlugin = require('html-webpack-plugin')
const CleanWebpackPlugin = require('clean-webpack-plugin')
const CopyWebpackPlugin = require('copy-webpack-plugin')

module.exports = env => {
    console.log('env.REACT_APP_USERNAME = ' + env.REACT_APP_USERNAME)
    return {
        mode: "development",entry: './src/main/js/app.js',output: {
            path: path.join(__dirname,'dist'),filename: 'bundle.js'
        },resolve: {
            extensions: ['.js','.jsx','.ts','.tsx']
        },module: {
            rules: [{
                loader: 'babel-loader',test: [/\.jsx?$/,/\.tsx?$/],exclude: [/node_modules/],options: {
                    presets: ['@babel/env','@babel/react'],plugins: ['transform-class-properties']
                }
            },{
                    test: /\.css$/,use: ["style-loader",MiniCssExtractPlugin.loader,"css-loader"]
                },{
                    test: /\.html$/,use: [
                        {
                            loader: "html-loader",options: {minimize: true}
                        }
                    ]
                },{
                    test: /\.(eot|woff|woff2|ttf|svg|gif|png)$/,use: [
                        {
                            loader: "file-loader"
                        }
                    ]
                }
            ]
        },devServer: {
            contentBase: path.join(__dirname,compress: true,port: 9000
        },plugins: [
            new webpack.DefinePlugin({
                'process.env.REACT_APP_ROUTER_BASE': JSON.stringify(env.REACT_APP_ROUTER_BASE || ''),'process.env.REACT_APP_USERNAME': JSON.stringify(env.REACT_APP_USERNAME || '')
            }),new MiniCssExtractPlugin({
                filename: "[name].css",chunkFilename: "[id].css"
            }),new HtmlWebPackPlugin({
                template: "./src/main/resources/static/index.html",filename: "index.html"
            }),new CopyWebpackPlugin([
                { from: 'src/main/resources/static/images',to: 'images'}
            ]),new webpack.HotModuleReplacementPlugin(),new CleanWebpackPlugin()
        ]
    }
};

解决方法

mb npm clean-install 会有所帮助

,

我通过比较 sandbox example 所需的依赖项来解决问题。

我的 package.json 没有以下依赖项:

  1. 反应选择

  2. 反应虚拟化

所以先安装上面的。以下显示了我使用的确切版本。

"react-select": "3.1.0","react-virtualized": "9.21.2"

然后安装了特定版本 2.5.7(他们在沙箱中使用的确切版本 here)。尽管他们在 doc 中提到了 For using this package with react-select 3.x,please use version 2.5.11.,但我决定坚持使用他们在沙箱中使用的 2.5.7。 因此我添加了以下版本:

"react-select-virtualized": "2.5.7",

我的代码编译没有任何问题。

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

相关推荐


使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams[&#39;font.sans-serif&#39;] = [&#39;SimHei&#39;] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -&gt; systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping(&quot;/hires&quot;) public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate&lt;String
使用vite构建项目报错 C:\Users\ychen\work&gt;npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-
参考1 参考2 解决方案 # 点击安装源 协议选择 http:// 路径填写 mirrors.aliyun.com/centos/8.3.2011/BaseOS/x86_64/os URL类型 软件库URL 其他路径 # 版本 7 mirrors.aliyun.com/centos/7/os/x86
报错1 [root@slave1 data_mocker]# kafka-console-consumer.sh --bootstrap-server slave1:9092 --topic topic_db [2023-12-19 18:31:12,770] WARN [Consumer clie
错误1 # 重写数据 hive (edu)&gt; insert overwrite table dwd_trade_cart_add_inc &gt; select data.id, &gt; data.user_id, &gt; data.course_id, &gt; date_format(
错误1 hive (edu)&gt; insert into huanhuan values(1,&#39;haoge&#39;); Query ID = root_20240110071417_fe1517ad-3607-41f4-bdcf-d00b98ac443e Total jobs = 1
报错1:执行到如下就不执行了,没有显示Successfully registered new MBean. [root@slave1 bin]# /usr/local/software/flume-1.9.0/bin/flume-ng agent -n a1 -c /usr/local/softwa
虚拟及没有启动任何服务器查看jps会显示jps,如果没有显示任何东西 [root@slave2 ~]# jps 9647 Jps 解决方案 # 进入/tmp查看 [root@slave1 dfs]# cd /tmp [root@slave1 tmp]# ll 总用量 48 drwxr-xr-x. 2
报错1 hive&gt; show databases; OK Failed with exception java.io.IOException:java.lang.RuntimeException: Error in configuring object Time taken: 0.474 se
报错1 [root@localhost ~]# vim -bash: vim: 未找到命令 安装vim yum -y install vim* # 查看是否安装成功 [root@hadoop01 hadoop]# rpm -qa |grep vim vim-X11-7.4.629-8.el7_9.x
修改hadoop配置 vi /usr/local/software/hadoop-2.9.2/etc/hadoop/yarn-site.xml # 添加如下 &lt;configuration&gt; &lt;property&gt; &lt;name&gt;yarn.nodemanager.res