npm运行部署失败

时间:2020-10-20 20:10:03

标签: reactjs npm deployment github-pages

我正在尝试将React.js应用程序部署到github页面,但是在构建过程中,我的终端出现2个错误。我该如何解决?

这是我的终端机

PS D:\front-end\GitHub\Project> npm run deploy

> app@0.1.0 predeploy D:\front-end\GitHub\Project
> npm run build


> app@0.1.0 build D:\front-end\GitHub\Project
> react-scripts build

Creating an optimized production build...
D:\front-end\GitHub\Project\node_modules\react-scripts\scripts\build.js:19
  throw err;
  ^

Error: Invalid mapping: {"generated":{"line":406,"column":4},"source":"../../node_modules/shards-ui/src/scss/mixins/_hover.scss","original":{"line":15,"column":-21},"name":null}
    at SourceMapGenerator_validateMapping [as _validateMapping] (D:\front-end\GitHub\Project\node_modules\webpack-sources\node_modules\source-map\lib\source-map-generator.js:298:13)
    at SourceMapGenerator_addMapping [as addMapping] (D:\front-end\GitHub\Project\node_modules\webpack-sources\node_modules\source-map\lib\source-map-generator.js:110:12)
    at D:\front-end\GitHub\Project\node_modules\webpack-sources\node_modules\source-map\lib\source-node.js:351:13
    at SourceNode_walk [as walk] (D:\front-end\GitHub\Project\node_modules\webpack-sources\node_modules\source-map\lib\source-node.js:230:9)
    at SourceNode_walk [as walk] (D:\front-end\GitHub\Project\node_modules\webpack-sources\node_modules\source-map\lib\source-node.js:226:13)
    at SourceNode_walk [as walk] (D:\front-end\GitHub\Project\node_modules\webpack-sources\node_modules\source-map\lib\source-node.js:226:13)
    at SourceNode_toStringWithSourceMap [as toStringWithSourceMap] (D:\front-end\GitHub\Project\node_modules\webpack-sources\node_modules\source-map\lib\source-node.js:342:8)
    at ConcatSource.proto.sourceAndMap (D:\front-end\GitHub\Project\node_modules\webpack-sources\lib\SourceAndMapMixin.js:29:32)    at CachedSource.sourceAndMap (D:\front-end\GitHub\Project\node_modules\webpack-sources\lib\CachedSource.js:58:31)
    at OptimizeCssAssetsWebpackPlugin.processCss (D:\front-end\GitHub\Project\node_modules\optimize-css-assets-webpack-plugin\src\index.js:44:44)
    at Object.processor (D:\front-end\GitHub\Project\node_modules\optimize-css-assets-webpack-plugin\src\index.js:13:18)        
    at D:\front-end\GitHub\Project\node_modules\last-call-webpack-plugin\src\index.js:150:10
    at arrayEach (D:\front-end\GitHub\Project\node_modules\lodash\_arrayEach.js:15:9)
    at forEach (D:\front-end\GitHub\Project\node_modules\lodash\forEach.js:38:10)
    at OptimizeCssAssetsWebpackPlugin.process (D:\front-end\GitHub\Project\node_modules\last-call-webpack-plugin\src\index.js:147:5)
    at D:\front-end\GitHub\Project\node_modules\last-call-webpack-plugin\src\index.js:178:28
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! app@0.1.0 build: `react-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the app@0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Miltosh\AppData\Roaming\npm-cache\_logs\2020-10-20T19_45_30_869Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! app@0.1.0 predeploy: `npm run build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the app@0.1.0 predeploy script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Miltosh\AppData\Roaming\npm-cache\_logs\2020-10-20T19_45_31_015Z-debug.log

这是第一个日志文件,名为“ _logs \ 2020-10-20T19_45_30_869Z-debug.log”:

0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   'D:\\Программы\\Node.js\\node.exe',
1 verbose cli   'D:\\Программы\\Node.js\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'run',
1 verbose cli   'build'
1 verbose cli ]
2 info using npm@6.14.6
3 info using node@v12.18.3
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle app@0.1.0~prebuild: app@0.1.0
6 info lifecycle app@0.1.0~build: app@0.1.0
7 verbose lifecycle app@0.1.0~build: unsafe-perm in lifecycle true
8 verbose lifecycle app@0.1.0~build: PATH: D:\Программы\Node.js\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;D:\front-end\GitHub\Project\node_modules\.bin;D:\Программы\Node.js\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;D:\front-end\GitHub\Project\node_modules\.bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;D:\Программы\Git\GitBash\cmd;D:\Программы\Node.js\;C:\Users\Miltosh\AppData\Local\Microsoft\WindowsApps;C:\Users\Miltosh\AppData\Roaming\npm;C:\Users\Miltosh\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\Miltosh\AppData\Local\GitHubDesktop\bin
9 verbose lifecycle app@0.1.0~build: CWD: D:\front-end\GitHub\Project
10 silly lifecycle app@0.1.0~build: Args: [ '/d /s /c', 'react-scripts build' ]
11 silly lifecycle app@0.1.0~build: Returned: code: 1  signal: null
12 info lifecycle app@0.1.0~build: Failed to exec build script
13 verbose stack Error: app@0.1.0 build: `react-scripts build`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (D:\Программы\Node.js\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:315:20)
13 verbose stack     at ChildProcess.<anonymous> (D:\Программы\Node.js\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:315:20)
13 verbose stack     at maybeClose (internal/child_process.js:1021:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
14 verbose pkgid app@0.1.0
15 verbose cwd D:\front-end\GitHub\Project
16 verbose Windows_NT 10.0.19041
17 verbose argv "D:\\Программы\\Node.js\\node.exe" "D:\\Программы\\Node.js\\node_modules\\npm\\bin\\npm-cli.js" "run" "build"
18 verbose node v12.18.3
19 verbose npm  v6.14.6
20 error code ELIFECYCLE
21 error errno 1
22 error app@0.1.0 build: `react-scripts build`
22 error Exit status 1
23 error Failed at the app@0.1.0 build script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

这是第二个日志文件,名为“ _logs \ 2020-10-20T19_45_31_015Z-debug.log”:

0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   'D:\\Программы\\Node.js\\node.exe',
1 verbose cli   'D:\\Программы\\Node.js\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'run',
1 verbose cli   'deploy'
1 verbose cli ]
2 info using npm@6.14.6
3 info using node@v12.18.3
4 verbose run-script [ 'predeploy', 'deploy', 'postdeploy' ]
5 info lifecycle app@0.1.0~predeploy: app@0.1.0
6 verbose lifecycle app@0.1.0~predeploy: unsafe-perm in lifecycle true
7 verbose lifecycle app@0.1.0~predeploy: PATH: D:\Программы\Node.js\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;D:\front-end\GitHub\Project\node_modules\.bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;D:\Программы\Git\GitBash\cmd;D:\Программы\Node.js\;C:\Users\Miltosh\AppData\Local\Microsoft\WindowsApps;C:\Users\Miltosh\AppData\Roaming\npm;C:\Users\Miltosh\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\Miltosh\AppData\Local\GitHubDesktop\bin
8 verbose lifecycle app@0.1.0~predeploy: CWD: D:\front-end\GitHub\Project
9 silly lifecycle app@0.1.0~predeploy: Args: [ '/d /s /c', 'npm run build' ]
10 silly lifecycle app@0.1.0~predeploy: Returned: code: 1  signal: null
11 info lifecycle app@0.1.0~predeploy: Failed to exec predeploy script
12 verbose stack Error: app@0.1.0 predeploy: `npm run build`
12 verbose stack Exit status 1
12 verbose stack     at EventEmitter.<anonymous> (D:\Программы\Node.js\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16)
12 verbose stack     at EventEmitter.emit (events.js:315:20)
12 verbose stack     at ChildProcess.<anonymous> (D:\Программы\Node.js\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
12 verbose stack     at ChildProcess.emit (events.js:315:20)
12 verbose stack     at maybeClose (internal/child_process.js:1021:16)
12 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
13 verbose pkgid app@0.1.0
14 verbose cwd D:\front-end\GitHub\Project
15 verbose Windows_NT 10.0.19041
16 verbose argv "D:\\Программы\\Node.js\\node.exe" "D:\\Программы\\Node.js\\node_modules\\npm\\bin\\npm-cli.js" "run" "deploy"
17 verbose node v12.18.3
18 verbose npm  v6.14.6
19 error code ELIFECYCLE
20 error errno 1
21 error app@0.1.0 predeploy: `npm run build`
21 error Exit status 1
22 error Failed at the app@0.1.0 predeploy script.
22 error This is probably not a problem with npm. There is likely additional logging output above.
23 verbose exit [ 1, true ]

和我的package.json,如果需要的话:

{
  "name": "app",
  "version": "0.1.0",
  "private": true,
  "homepage": "https://user.github.io/project",
  "dependencies": {
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.5.0",
    "@testing-library/user-event": "^7.2.1",
    "bootstrap": "^4.5.3",
    "gh-pages": "^3.1.0",
    "npm-force-resolutions": "0.0.3",
    "react": "^16.14.0",
    "react-dom": "^16.14.0",
    "react-scripts": "3.4.3"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject",
    "predeploy": "npm run build",
    "deploy": "gh-pages -d build",
    "preinstall": "npx npm-force-resolutions"
  },
  "resolutions": {
    "object-path": "^0.11.5"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

我试图修复一些依赖关系,但是并没有改变任何东西。以前,我已将其他项目上传到github页面,以前从未遇到过这样的问题

0 个答案:

没有答案