在我的React create-react-app项目中,npm start可以正常工作,但是“ build”脚本几乎立即失败。
错误提示无法编译-'EISDIR:对目录进行非法操作,已读取'
我尝试使用nvm完全卸载并重新安装node&npm。
我尝试创建一个新的create-react-app项目而不编辑任何预加载的代码,但是构建仍然失败。
终端错误消息:
Creating an optimized production build...
Failed to compile.
EISDIR: illegal operation on a directory, read
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! personal-website@0.1.0 build: react-scripts build
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the personal-website@0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
调试日志:
0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli '/Users/Stew/.nvm/versions/node/v12.7.0/bin/node',
1 verbose cli '/Users/Stew/.nvm/versions/node/v12.7.0/bin/npm',
1 verbose cli 'run',
1 verbose cli 'build'
1 verbose cli ]
2 info using npm@6.10.2
3 info using node@v12.7.0
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle personal-website@0.1.0~prebuild: personal-website@0.1.0
6 info lifecycle personal-website@0.1.0~build: personal-website@0.1.0
7 verbose lifecycle personal-website@0.1.0~build: unsafe-perm in lifecycle true
8 verbose lifecycle personal-website@0.1.0~build: PATH: /Users/Stew/.nvm/versions/node/v12.7.0/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/Stew/Desktop/personal-website/node_modules/.bin:/Users/Stew/.nvm/versions/node/v12.7.0/bin:/usr/bin:/usr/sbin:/bin:/sbin
9 verbose lifecycle personal-website@0.1.0~build: CWD: /Users/Stew/Desktop/personal-website
10 silly lifecycle personal-website@0.1.0~build: Args: [ '-c', 'react-scripts build' ]
11 silly lifecycle personal-website@0.1.0~build: Returned: code: 1 signal: null
12 info lifecycle personal-website@0.1.0~build: Failed to exec build script
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (/Users/Stew/.nvm/versions/node/v12.7.0/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:326:16)
13 verbose stack at EventEmitter.emit (events.js:203:13)
13 verbose stack at ChildProcess.<anonymous> (/Users/Stew/.nvm/versions/node/v12.7.0/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:203:13)
13 verbose stack at maybeClose (internal/child_process.js:1021:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)
14 verbose pkgid personal-website@0.1.0
15 verbose cwd /Users/Stew/Desktop/personal-website
16 verbose Darwin 18.6.0
17 verbose argv "/Users/Stew/.nvm/versions/node/v12.7.0/bin/node" "/Users/Stew/.nvm/versions/node/v12.7.0/bin/npm" "run" "build"
18 verbose node v12.7.0
19 verbose npm v6.10.2
20 error code ELIFECYCLE
21 error errno 1
22 error personal-website@0.1.0 build: `react-scripts build`
22 error Exit status 1
23 error Failed at the personal-website@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 ]
package.json
{
"name": "personal-website",
"version": "0.1.0",
"private": true,
"dependencies": {
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-scripts": "3.0.1"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"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"
]
}
}
我希望react项目能够成功编译生产构建脚本,但它会创建构建存储库,并在创建manifest.json后立即失败并给出上面列出的错误消息。