【问题标题】:path.js:1086 Error: ENOENT: no such file or directory, uv_cwdpath.js:1086 错误:ENOENT:没有这样的文件或目录,uv_cwd
【发布时间】:2019-04-19 14:34:40
【问题描述】:

我遵循 Webpack 指南,在运行 npm run build 时卡住了 here 我收到了这个错误:

path.js:1086
          cwd = process.cwd();
                        ^

Error: ENOENT: no such file or directory, uv_cwd
    at Object.resolve (path.js:1086:25)
    at Function.Module._resolveLookupPaths (internal/modules/cjs/loader.js:479:17)
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:587:20)

我检查了所有进口,一切看起来都很好。比我想的应该是缓存问题,所以我跑了npm cache clean -f,令人惊讶的是我得到了完全相同的错误。可能是 NodeJS 问题,但我不知道如何调试它。

这是我的文件结构:

package.json

{
  "name": "test_webpack",
  "version": "1.0.0",
  "description": "",
  "private": true,
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "build": "webpack"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "clean-webpack-plugin": "^1.0.0",
    "css-loader": "^1.0.1",
    "csv-loader": "^3.0.2",
    "file-loader": "^2.0.0",
    "html-webpack-plugin": "^3.2.0",
    "style-loader": "^0.23.1",
    "webpack": "^4.25.1",
    "webpack-cli": "^3.1.2",
    "xml-loader": "^1.2.1"
  },
  "dependencies": {
    "lodash": "^4.17.11"
  }
}

webpack.config.js

const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin')
const CleanWebpackPlugin = require('clean-webpack-plugin')

module.exports = {
  mode: 'development',
  entry: {
    app: './src/index.js',
    print: './src/print.js',
    sec: './src/secondClick.js'
  },
  devtool: 'inline-source-map',
  plugins: [
    new CleanWebpackPlugin(['dist']),
    new HtmlWebpackPlugin({
      titile: "Output manager from webpack n12"
    })
  ],
  output: {
    filename: '[name].bundle.js',
    path: path.resolve(__dirname, 'dist')
  }
};

【问题讨论】:

    标签: node.js npm webpack


    【解决方案1】:

    尝试更改您的webpack.config

      entry: {
        app: path.resolve(__dirname, 'src/index.js'),
        print: path.resolve(__dirname, 'src/print.js'),
        sec: path.resolve(__dirname, 'src/secondClick.js')
      },
    

    并确保从项目根目录运行命令: npx webpack --config webpack.config.js

    【讨论】:

    • 您使用什么操作系统?运行构建命令的pwd 是什么?
    • Ubuntu 16.04 我尝试从项目的根目录和 dist 文件夹中运行它
    • 留在项目根目录并尝试使用npx webpack --config webpack.config.js运行它
    • 成功了,谢谢。编辑您的答案,以便我接受它
    【解决方案2】:

    重启电脑也可能有帮助。

    【讨论】:

      【解决方案3】:

      关闭所有终端窗口并再次打开它对我有用。

      Reference

      【讨论】:

      • 此解决方案在 Visual Studio Code 中有效。谢谢!
      • 你救了我几个小时,先生:D
      • 您可能像我一样在另一个终端窗口的同一目录中运行git clone
      【解决方案4】:

      看来你的 shell 快疯了 :), 只需cd.. && cd [the folder you tried running the command],一切都会恢复正常。

      【讨论】:

      • 这个解决方案更简单,应该被接受,而不是丢失所有终端标签
      • 您所在的目录已被删除(可能已创建另一个同名目录)。把它想象成死亡和醒来你转世的身体,认为你还在你的旧身体里。在你回到你的新现实之前,你必须上升。
      猜你喜欢
      • 2019-01-05
      • 1970-01-01
      • 2017-10-07
      • 1970-01-01
      • 2019-03-09
      • 2017-12-28
      • 2022-01-16
      • 2021-03-30
      • 1970-01-01
      相关资源
      最近更新 更多