Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Webpack 接收';错误:Can';t解决<;自定义模块名称>';尝试在本地使用自定义生成模块时_Webpack_Npm Install_Node Modules_Package.json_Npm Link - Fatal编程技术网

Webpack 接收';错误:Can';t解决<;自定义模块名称>';尝试在本地使用自定义生成模块时

Webpack 接收';错误:Can';t解决<;自定义模块名称>';尝试在本地使用自定义生成模块时,webpack,npm-install,node-modules,package.json,npm-link,Webpack,Npm Install,Node Modules,Package.json,Npm Link,我正在尝试导入我在本地创建并链接/安装到另一个模块的模块,该模块是通过webpack构建和运行的 我使用了多种方法将自定义模块集成到其他模块中: npm link自定义模块,用于创建符号链接,该链接显示在另一个模块的node\u modules目录中 npm安装安装它的自定义模块 使用wml()将自定义模块中更改的文件复制到node\u模块中 将自定义模块发布到npm,然后将其安装到其他模块中 所有这些方法仍然导致显示的网页和流无法解决错误 NPM版本:6.9.1-next.0 节点版本:8.8

我正在尝试导入我在本地创建并链接/安装到另一个模块的模块,该模块是通过webpack构建和运行的

我使用了多种方法将自定义模块集成到其他模块中:

  • npm link
    自定义模块,用于创建符号链接,该链接显示在另一个模块的
    node\u modules
    目录中
  • npm安装
    安装它的自定义模块
  • 使用
    wml
    ()将自定义模块中更改的文件复制到
    node\u模块中
  • 将自定义模块发布到
    npm
    ,然后将其安装到其他模块中
  • 所有这些方法仍然导致显示
    的网页和流无法解决
    错误

    NPM版本:
    6.9.1-next.0
    节点版本:
    8.8.1

    以下是自定义模块的
    package.json
    文件:

    {
      "name": "custom_module_name",
      "version": "2.3.0",
      "repository": {
        "type": "git",
        "url": "-----"
      },
      "license": "UNLICENSED",
      "engines": {
        "node": ">=10.10.0",
        "npm": ">=6.4.1"
      },
      "ava": {
        "files": [
          ".test/**/*.js"
        ],
        "require": [
          "./test/helpers/config.js",
          "./test/helpers/utils.js"
        ],
        "babel": {
          "testOptions": {
            "babelrc": false
          }
        },
        "sources": [
          ".dist/**/*"
        ],
        "serial": true,
        "verbose": true,
        "failFast": false,
        "color": true,
        "concurrency": 1,
        "failWithoutAssertions": false,
        "tap": false,
        "timeout": "180s"
      },
      "nightmare": {
        "doc": true,
        "show": true,
        "openDevTools": {
          "mode": "detach"
        },
        "executionTimeout": 10000,
        "waitTimeout": 120000,
        "webPreferences": {
          "partition": "nopersist"
        },
        "switches": {
          "ignore-certificate-errors": true
        },
        "show_console_logging": false
      },
      "glslify": {
        "transform": [
          "glslify-import"
        ]
      }
    }
    
    const webpack = require('webpack');
    const path = require('path');
    const glob = require('glob');
    const ExtractTextPlugin = require("extract-text-webpack-plugin");
    const FlowWebpackPlugin = require('flow-webpack-plugin');
    
    module.exports = {
      entry: {
        vendor: ['babel-polyfill', 'react', 'react-dom'],
        annotationService: glob.sync('./ClientScripts/---/*.js'),
        sass: './sass/main.scss'
      },
      output: {
        path: path.join(__dirname, 'reactDist'),
        filename: 'js/[name].js',
        publicPath: '/---/',
        sourceMapFilename: 'map/[name].map'
      },
      optimization: {
        runtimeChunk: 'single',
        splitChunks: {
          cacheGroups: {
            vendor: {
              test: /[\\/]node_modules[\\/]/,
              name: 'vendors',
              chunks: 'all'
            }
          }
        }
      },
      resolve: {
        alias: {
          Interfaces: path.resolve(__dirname, 'ClientScripts/Interfaces/'),
          "custom_module_name": path.resolve(__dirname, 'node_modules/custom_module_name/')
        },
        symlinks: false
      },
      target: 'web',
      node: {
        fs: "empty"
      },
      externals: {
        'winston': 'require("winston")' // https://stackoverflow.com/questions/37840566/how-do-i-get-winston-to-work-with-webpack/37841103
      },
      module: {
        rules: [
          { test: /\.js$/, loader: 'babel-loader', exclude: [/node_modules/] },
          { test: /\.jsx$/, loader: 'babel-loader', exclude: [/node_modules/] },
          { test: /\.env$/, loader: "file-loader?name=index.[ext]", exclude: [/node_modules/] },
          {
            test: /\.scss$|\.css$/,
            exclude: /node_modules/,
            loader: ExtractTextPlugin.extract({
              use: [{
                loader: "css-loader",
                options: {
                  minimize: true
                }
              },'sass-loader']
            })
          },
          { test: /\.(jpe?g|png|gif|svg)$/,
            loader: 'file-loader?name=img/[name].[ext]?',
            options: {
              name (file) {
                if (process.env.environment === 'prod') {
                  return '[path][name].[hash].[ext]'
                }
    
                return '[path][name].[ext]'
              }
            }
          }
        ]
      },
      plugins: [
        new ExtractTextPlugin({ filename: 'css/timeline.[md5:contenthash:hex:20].css', disable: false, allChunks: true }),
        new FlowWebpackPlugin()
      ]
    }
    
    以下是另一个试图导入自定义模块的模块的
    webpack.common.js
    文件:

    {
      "name": "custom_module_name",
      "version": "2.3.0",
      "repository": {
        "type": "git",
        "url": "-----"
      },
      "license": "UNLICENSED",
      "engines": {
        "node": ">=10.10.0",
        "npm": ">=6.4.1"
      },
      "ava": {
        "files": [
          ".test/**/*.js"
        ],
        "require": [
          "./test/helpers/config.js",
          "./test/helpers/utils.js"
        ],
        "babel": {
          "testOptions": {
            "babelrc": false
          }
        },
        "sources": [
          ".dist/**/*"
        ],
        "serial": true,
        "verbose": true,
        "failFast": false,
        "color": true,
        "concurrency": 1,
        "failWithoutAssertions": false,
        "tap": false,
        "timeout": "180s"
      },
      "nightmare": {
        "doc": true,
        "show": true,
        "openDevTools": {
          "mode": "detach"
        },
        "executionTimeout": 10000,
        "waitTimeout": 120000,
        "webPreferences": {
          "partition": "nopersist"
        },
        "switches": {
          "ignore-certificate-errors": true
        },
        "show_console_logging": false
      },
      "glslify": {
        "transform": [
          "glslify-import"
        ]
      }
    }
    
    const webpack = require('webpack');
    const path = require('path');
    const glob = require('glob');
    const ExtractTextPlugin = require("extract-text-webpack-plugin");
    const FlowWebpackPlugin = require('flow-webpack-plugin');
    
    module.exports = {
      entry: {
        vendor: ['babel-polyfill', 'react', 'react-dom'],
        annotationService: glob.sync('./ClientScripts/---/*.js'),
        sass: './sass/main.scss'
      },
      output: {
        path: path.join(__dirname, 'reactDist'),
        filename: 'js/[name].js',
        publicPath: '/---/',
        sourceMapFilename: 'map/[name].map'
      },
      optimization: {
        runtimeChunk: 'single',
        splitChunks: {
          cacheGroups: {
            vendor: {
              test: /[\\/]node_modules[\\/]/,
              name: 'vendors',
              chunks: 'all'
            }
          }
        }
      },
      resolve: {
        alias: {
          Interfaces: path.resolve(__dirname, 'ClientScripts/Interfaces/'),
          "custom_module_name": path.resolve(__dirname, 'node_modules/custom_module_name/')
        },
        symlinks: false
      },
      target: 'web',
      node: {
        fs: "empty"
      },
      externals: {
        'winston': 'require("winston")' // https://stackoverflow.com/questions/37840566/how-do-i-get-winston-to-work-with-webpack/37841103
      },
      module: {
        rules: [
          { test: /\.js$/, loader: 'babel-loader', exclude: [/node_modules/] },
          { test: /\.jsx$/, loader: 'babel-loader', exclude: [/node_modules/] },
          { test: /\.env$/, loader: "file-loader?name=index.[ext]", exclude: [/node_modules/] },
          {
            test: /\.scss$|\.css$/,
            exclude: /node_modules/,
            loader: ExtractTextPlugin.extract({
              use: [{
                loader: "css-loader",
                options: {
                  minimize: true
                }
              },'sass-loader']
            })
          },
          { test: /\.(jpe?g|png|gif|svg)$/,
            loader: 'file-loader?name=img/[name].[ext]?',
            options: {
              name (file) {
                if (process.env.environment === 'prod') {
                  return '[path][name].[hash].[ext]'
                }
    
                return '[path][name].[ext]'
              }
            }
          }
        ]
      },
      plugins: [
        new ExtractTextPlugin({ filename: 'css/timeline.[md5:contenthash:hex:20].css', disable: false, allChunks: true }),
        new FlowWebpackPlugin()
      ]
    }
    
    这是我的
    .flowconfig

    [ignore]
    .*/node_modules/flow-webpack-plugin/.*
    .*/node_modules/custom-module-name/.*
    .*/node_modules/custom-module-name/**/test/.*
    .*/node_modules/.*\.json$
    .*/node_modules/\.staging/.*
    
    [libs]
    flow-typed
    
    [options]
    module.name_mapper='^Interfaces\/\(.*\)$' -> '<PROJECT_ROOT>/ClientScripts/Interfaces/\1'
    module.file_ext=.js
    module.file_ext=.jsx
    module.file_ext=.svg
    module.file_ext=.json
    
    我相信这是来自网页包

    ERROR in Flow validation
    Error ------------------------------------------ ClientScripts/-/DashboardGrid.jsx:11:22
    
    Cannot resolve module custom_module_name.
    
          8| const ReactGridLayout = WidthProvider(RGL);
          9|
         10| // AKDV
         11| import { Test } from 'custom_module_name';
    
    它来自于流动

    我假设问题源于自定义模块设置本身…知道它可能有什么问题吗