如何修复未知的npm run build错误

huangapple go评论84阅读模式
英文:

How can I fix unknown npm run build error

问题

我在键入"npm run build"时遇到了错误,然而,我在4个月前创建了这个项目,当时没有这样的错误,现在我需要我的网站。这是我收到的错误信息:

$ npm run build

> honest-trading@0.1.0 build
> react-scripts build

    node:internal/fs/utils:347
        throw err;
        ^

    Error: UNKNOWN: unknown error, read
        at Object.readSync (node:fs:748:3)
        at tryReadSync (node:fs:448:20)
        at Object.readFileSync (node:fs:486:19)
        at C:\Users\rusla\OneDrive\Рабочий стол\Sites\honesttrading\honest-trading\node_modules\react-dev-utils\FileSizeReporter.js:139:29
        at Array.reduce (<anonymous>)
        at C:\Users\rusla\OneDrive\Рабочий стол\Sites\honesttrading\honest-trading\node_modules\react-dev-utils\FileSizeReporter.js:138:48
        at C:\Users\rusla\OneDrive\Рабочий стол\Sites\honesttrading\honest-trading\node_modules\recursive-readdir\index.js:81:22
        at C:\Users\rusla\OneDrive\Рабочий стол\Sites\honesttrading\honest-trading\node_modules\recursive-readdir\index.js:81:22
        at C:\Users\rusla\OneDrive\Рабочий стол\Sites\honesttrading\honest-trading\node_modules\recursive-readdir\index.js:88:20
        at FSReqCallback.oncomplete (node:fs:208:5) {
      errno: -4094,
      syscall: 'read',
      code: 'UNKNOWN'
    }
    
    Node.js v18.14.2

如何修复它?

我尝试键入"npm start",得到了以下错误:

rror: error:0308010C:digital envelope routines::unsupported
        at new Hash (node:internal/crypto/hash:71:19)
        at Object.createHash (node:crypto:133:10)
        at module.exports (C:\Users\rusla\OneDrive\Рабочий стол\Sites\honesttrading\honest-trading\node_modules\webpack\lib\util\createHash.js:90:53)
        at NormalModule._initBuildHash (C:\Users\rusla\OneDrive\Рабочий стол\Sites\honesttrading\honest-trading\node_modules\webpack\lib\NormalModule.js:386:16)
        at C:\Users\rusla\OneDrive\Рабочий стол\Sites\honesttrading\honest-trading\node_modules\webpack\lib\NormalModule.js:418:10
        at C:\Users\rusla\OneDrive\Рабочий стол\Sites\honesttrading\honest-trading\node_modules\webpack\lib\NormalModule.js:293:13
        at C:\Users\rusla\OneDrive\Рабочий стол\Sites\honesttrading\honest-trading\node_modules\loader-runner\lib\LoaderRunner.js:367:11
        at C:\Users\rusla\OneDrive\Рабочий стол\Sites\honesttrading\honest-trading\node_modules\loader-runner\lib\LoaderRunner.js:233:18
        at context.callback (C:\Users\rusla\OneDrive\Рабочий стол\Sites\honesttrading\honest-trading\node_modules\loader-runner\lib\LoaderRunner.js:111:13)
        at C:\Users\rusla\OneDrive\Рабочий стол\Sites\honesttrading\honest-trading\node_modules\babel-loader\lib\index.js:51:103 {
      opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],      
      library: 'digital envelope routines',
      reason: 'unsupported',
      code: 'ERR_OSSL_EVP_UNSUPPORTED'
    }
    
    Node.js v18.14.2
英文:

I have an error when I'm typing "npm run build", however, I made this project 4 month ago and there wasn't error like that, now I need to my website. This is an error, that I'm receiving:

$ npm run build

> honest-trading@0.1.0 build
> react-scripts build

node:internal/fs/utils:347
    throw err;
    ^

Error: UNKNOWN: unknown error, read
    at Object.readSync (node:fs:748:3)
    at tryReadSync (node:fs:448:20)
    at Object.readFileSync (node:fs:486:19)
    at C:\Users\rusla\OneDrive\Рабочий стол\Sites\honesttrading\honest-trading\node_modules\react-dev-utils\FileSizeReporter.js:139:29
    at Array.reduce (&lt;anonymous&gt;)
    at C:\Users\rusla\OneDrive\Рабочий стол\Sites\honesttrading\honest-trading\node_modules\react-dev-utils\FileSizeReporter.js:138:48
    at C:\Users\rusla\OneDrive\Рабочий стол\Sites\honesttrading\honest-trading\node_modules\recursive-readdir\index.js:81:22
    at C:\Users\rusla\OneDrive\Рабочий стол\Sites\honesttrading\honest-trading\node_modules\recursive-readdir\index.js:81:22
    at C:\Users\rusla\OneDrive\Рабочий стол\Sites\honesttrading\honest-trading\node_modules\recursive-readdir\index.js:88:20
    at FSReqCallback.oncomplete (node:fs:208:5) {
  errno: -4094,
  syscall: &#39;read&#39;,
  code: &#39;UNKNOWN&#39;
}

Node.js v18.14.2

How to fix it?

I have tried to type "npm start" and got this:

rror: error:0308010C:digital envelope routines::unsupported
    at new Hash (node:internal/crypto/hash:71:19)
    at Object.createHash (node:crypto:133:10)
    at module.exports (C:\Users\rusla\OneDrive\Рабочий стол\Sites\honesttrading\honest-trading\node_modules\webpack\lib\util\createHash.js:90:53)
    at NormalModule._initBuildHash (C:\Users\rusla\OneDrive\Рабочий стол\Sites\honesttrading\honest-trading\node_modules\webpack\lib\NormalModule.js:386:16)
    at C:\Users\rusla\OneDrive\Рабочий стол\Sites\honesttrading\honest-trading\node_modules\webpack\lib\NormalModule.js:418:10
    at C:\Users\rusla\OneDrive\Рабочий стол\Sites\honesttrading\honest-trading\node_modules\webpack\lib\NormalModule.js:293:13
    at C:\Users\rusla\OneDrive\Рабочий стол\Sites\honesttrading\honest-trading\node_modules\loader-runner\lib\LoaderRunner.js:367:11
    at C:\Users\rusla\OneDrive\Рабочий стол\Sites\honesttrading\honest-trading\node_modules\loader-runner\lib\LoaderRunner.js:233:18
    at context.callback (C:\Users\rusla\OneDrive\Рабочий стол\Sites\honesttrading\honest-trading\node_modules\loader-runner\lib\LoaderRunner.js:111:13)
    at C:\Users\rusla\OneDrive\Рабочий стол\Sites\honesttrading\honest-trading\node_modules\babel-loader\lib\index.js:51:103 {
  opensslErrorStack: [ &#39;error:03000086:digital envelope routines::initialization error&#39; ],      
  library: &#39;digital envelope routines&#39;,
  reason: &#39;unsupported&#39;,
  code: &#39;ERR_OSSL_EVP_UNSUPPORTED&#39;
}

Node.js v18.14.2

答案1

得分: 1

问题要么是由于损坏的文件,要么是由于旧缓存文件引起的。

对于缓存问题,请运行以下命令:

npm cache clear --force

正如**@heisenberg所提到的,您可以尝试删除您的包锁定文件,然后重新安装。**

英文:

The issue is either due to the corrupted files or old cache files.

For the cache problem run the following command:

npm cache clear --force

As @heisenberg mentioned you can try removing your package lock and install again.

答案2

得分: 0

错误可能是由于您的Node.js版本引起的,请运行以下命令查看版本:

node -v

有可能需要将您的Node.js版本降级,因为您的项目已经有4个月了。为此,您可以使用NVM来管理多个Node.js版本。使用以下命令来选择特定的Node.js版本:

nvm use 您的特定版本
英文:

The error may be coming because of your nodejs versions run the command

node -v

there may be a chance that your nodejs version needs to be downgraded as your project is 4 months old. For this you can use NVM to achieve multiple node versions.use the following command to use a specific node version.

nvm use your_specific_version

huangapple
  • 本文由 发表于 2023年7月24日 16:20:52
  • 转载请务必保留本文链接:https://go.coder-hub.com/76752604.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定