相关疑难解决方法(0)

webpack:找不到模块:错误:无法解析(使用相对路径)

我有一个app的结构(node_modulesdir从这个列表中排除):

??? actions.js
??? bundle.js
??? components
?   ??? App.js
?   ??? Footer.js
?   ??? Link.js
?   ??? Todo.js
?   ??? TodoList.js
??? Containers
?   ??? AddTodo.js
?   ??? FilterLink.js
?   ??? VisibleTodoList.js
??? index.html
??? index.js
??? main.js
??? package.json
??? package-lock.json
??? reducers.js
??? webpack.config.js
Run Code Online (Sandbox Code Playgroud)

我的webpack配置如下所示:

module.exports = {
    entry: "./main.js",
    output: {
        path: __dirname,
        filename: "bundle.js"
    },
    module: {
        loaders: [
          {
            test: /\.js$/,
            loader: 'babel-loader',
            query: {
              presets: ['es2015', 'react']
            }
          }
        ]
    } …
Run Code Online (Sandbox Code Playgroud)

javascript relative-path npm webpack

12
推荐指数
5
解决办法
5万
查看次数

由于“Module not found: Error: Can't resolve”错误,Webpack 突然无法编译

截至昨天下午,我们的 Javascript 单元测试套件开始失败。在出现一串 Module not found 错误后,没有任何测试运行并且 webpack 报告构建失败。这是我们的构建堆栈:

Node 6.11.5(是的,我知道,很旧) Karma 1.7.1 Webpack 2.2.1 React 15.6.2

我们使用 Karma 运行我们的单元测试。大部分测试套件都涉及 React,所以我们使用 Webpack 来构建一切。为此,我们导入我们的 webpack 配置,然后将各种值插入 Karma webpack 配置。

直接使用 Webpack 构建脚本工作正常,但是当我们尝试运行时,karma start我们会遇到很多这样的错误:

ERROR in ./~/object.entries/implementation.js
Module not found: Error: Can't resolve 'es-abstract/2019/RequireObjectCoercible' in '/jenkins/workspace/RFD/DCS/assets-build/build-js/node_modules/object.entries'
 @ ./~/object.entries/implementation.js 3:29-79
 @ ./~/object.entries/index.js
 @ ./~/enzyme/build/Utils.js
 @ ./~/enzyme/build/ReactWrapper.js
 @ ./~/enzyme/build/index.js
 @ ../sources/admin/js/pages/sponsored/organic_flyers/tests/DealerAddButton.spec.jsx

ERROR in ./~/object.fromentries/implementation.js
Module not found: Error: Can't resolve 'es-abstract/2019/AddEntriesFromIterable' in '/jenkins/workspace/RFD/DCS/assets-build/build-js/node_modules/object.fromentries'
 @ ./~/object.fromentries/implementation.js 3:29-79
 @ ./~/object.fromentries/index.js
 @ ./~/enzyme-adapter-utils/build/Utils.js
 @ ./~/enzyme-adapter-utils/build/index.js …
Run Code Online (Sandbox Code Playgroud)

node.js karma-runner reactjs webpack

7
推荐指数
1
解决办法
6240
查看次数

Vue 3 - 如何将 Polyfill 添加到 ChainWebpack

使用 Vue 3,如何添加path-browserify到 vue.config.js?

module.exports = {
    chainWebpack: config => {}
}
Run Code Online (Sandbox Code Playgroud)

编译时我收到以下错误:

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "path": require.resolve("path-browserify") }'
        - install 'path-browserify'
If you don't want to include a polyfill, you can …
Run Code Online (Sandbox Code Playgroud)

javascript webpack vue.js babeljs vuejs3

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

找不到模块:错误:无法解析“ crypto”

我在运行时收到以下错误列表ng serve

我的包JSON如下:

{   "name": "ProName",   "version": "0.0.0",   "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"   },   "private": true,   "dependencies": {
    "@angular-devkit/build-angular": "~0.12.0",
    "@angular/animations": "5.2.10",
    "@angular/common": "5.2.10",
    "@angular/compiler": "5.2.10",
    "@angular/compiler-cli": "5.2.10",
    "@angular/core": "5.2.10",
    "@angular/forms": "5.2.10",
    "@angular/platform-browser": "5.2.10",
    "@angular/platform-browser-dynamic": "5.2.10",
    "@angular/router": "5.2.10",
    "@types/dotenv": "^4.0.3",
    "@types/errorhandler": "0.0.32",
    "@types/express": "^4.16.0",
    "@types/node": "^10.5.1",
    "apostille-library": "^7.1.0",
    "core-js": "^2.5.4",
    "dotenv": "^6.0.0",
    "errorhandler": "^1.5.0",
    "express": "^4.16.0",
    "nem2-sdk": "^0.9.7",
    "rxjs": "~6.3.3",
    "stream": "0.0.2",
    "tslib": "^1.9.0", …
Run Code Online (Sandbox Code Playgroud)

javascript node.js npm angular nem

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