我无法创建npm install
或npm start command
。当我尝试npm install
时,控制台返回:
undefined postinstall C:\Users\Aristophanes
> cd packages/react-error-overlay/ && yarn build:prod
bash: line 0: cd: packages/react-error-overlay/: No such file or directory
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! undefined postinstall: `cd packages/react-error-overlay/ && yarn build:prod`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the undefined postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
日志链接:https://www.dropbox.com/s/1xckz3t8e4vbyur/2018-11-08T07_01_43_968Z-debug.log?dl=0
首先,我不太确定为什么要查找packages/react-error-overlay/
目录,但是我认为控制台可能是在计算机上的
C:\ Users \ Aristophanes \ create-react-app-next \ packages \ react-error-overlay
因为这是唯一在其路径中带有react-error-overlay
前缀的packages/
目录。如果我在cmd中打开该目录并尝试npm start
,则会收到此错误:
> react-error-overlay@4.0.0 start C:\Users\Aristophanes\create-react-app-next\packages\react-error-overlay
> cross-env NODE_ENV=development node build.js --watch
bash: cross-env: command not found
npm ERR! file bash npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! react-error-overlay@4.0.0 start: cross-env NODE_ENV=development node build.js --watch
npm ERR! spawn ENOENT npm ERR!
npm ERR! Failed at the react-error-overlay@4.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?
日志链接:https://www.dropbox.com/s/ibh87l08d65vcq5/2018-11-08T06_59_07_881Z-debug.log?dl=0
有什么想法可以解决这个问题吗?这是我的package.json文件:
{
"version": "6.4.1",
"name": "npm",
"description": "a package manager for JavaScript",
"keywords": [
"install",
"modules",
"package manager",
"package.json"
],
"preferGlobal": true,
"config": {
"publishtest": false
},
"homepage": "https://docs.npmjs.com/",
"author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me)",
"repository": {
"type": "git",
"url": "https://github.com/npm/cli"
},
"bugs": {
"url": "https://npm.community/c/bugs"
},
"directories": {
"bin": "./bin",
"doc": "./doc",
"lib": "./lib",
"man": "./man"
},
"main": "./lib/npm.js",
"bin": {
"npm": "./bin/npm-cli.js",
"npx": "./bin/npx-cli.js"
},
"dependencies": {
"JSONStream": "^1.3.4",
"abbrev": "~1.1.1",
"ansicolors": "~0.3.2",
"ansistyles": "~0.1.3",
"aproba": "~1.2.0",
"archy": "~1.0.0",
"bin-links": "^1.1.2",
"bluebird": "~3.5.1",
"byte-size": "^4.0.3",
"cacache": "^11.2.0",
"call-limit": "~1.1.0",
"chownr": "~1.0.1",
"ci-info": "^1.4.0",
"cli-columns": "^3.1.2",
"cli-table3": "^0.5.0",
"cmd-shim": "~2.0.2",
"columnify": "~1.5.4",
"config-chain": "~1.1.11",
"detect-indent": "~5.0.0",
"detect-newline": "^2.1.0",
"dezalgo": "~1.0.3",
"editor": "~1.0.0",
"figgy-pudding": "^3.4.1",
"find-npm-prefix": "^1.0.2",
"fs-vacuum": "~1.2.10",
"fs-write-stream-atomic": "~1.0.10",
"gentle-fs": "^2.0.1",
"glob": "~7.1.2",
"graceful-fs": "~4.1.11",
"has-unicode": "~2.0.1",
"hosted-git-info": "^2.7.1",
"iferr": "^1.0.2",
"inflight": "~1.0.6",
"inherits": "~2.0.3",
"ini": "^1.3.5",
"init-package-json": "^1.10.3",
"is-cidr": "^2.0.6",
"json-parse-better-errors": "^1.0.2",
"lazy-property": "~1.0.0",
"libcipm": "^2.0.2",
"libnpmhook": "^4.0.1",
"libnpx": "^10.2.0",
"lock-verify": "^2.0.2",
"lockfile": "^1.0.4",
"lodash._baseuniq": "~4.6.0",
"lodash.clonedeep": "~4.5.0",
"lodash.union": "~4.6.0",
"lodash.uniq": "~4.5.0",
"lodash.without": "~4.4.0",
"lru-cache": "^4.1.3",
"meant": "~1.0.1",
"mississippi": "^3.0.0",
"mkdirp": "~0.5.1",
"move-concurrently": "^1.0.1",
"node-gyp": "^3.8.0",
"nopt": "~4.0.1",
"normalize-package-data": "~2.4.0",
"npm-audit-report": "^1.3.1",
"npm-cache-filename": "~1.0.2",
"npm-install-checks": "~3.0.0",
"npm-lifecycle": "^2.1.0",
"npm-package-arg": "^6.1.0",
"npm-packlist": "^1.1.11",
"npm-pick-manifest": "^2.1.0",
"npm-profile": "^3.0.2",
"npm-registry-client": "^8.6.0",
"npm-registry-fetch": "^1.1.0",
"npm-user-validate": "~1.0.0",
"npmlog": "~4.1.2",
"once": "~1.4.0",
"opener": "^1.5.0",
"osenv": "^0.1.5",
"pacote": "^8.1.6",
"path-is-inside": "~1.0.2",
"promise-inflight": "~1.0.1",
"qrcode-terminal": "^0.12.0",
"query-string": "^6.1.0",
"qw": "~1.0.1",
"read": "~1.0.7",
"read-cmd-shim": "~1.0.1",
"read-installed": "~4.0.3",
"read-package-json": "^2.0.13",
"read-package-tree": "^5.2.1",
"readable-stream": "^2.3.6",
"request": "^2.88.0",
"retry": "^0.12.0",
"rimraf": "~2.6.2",
"safe-buffer": "^5.1.2",
"semver": "^5.5.0",
"sha": "~2.0.1",
"slide": "~1.1.6",
"sorted-object": "~2.0.1",
"sorted-union-stream": "~2.1.3",
"ssri": "^6.0.0",
"stringify-package": "^1.0.0",
"tar": "^4.4.6",
"text-table": "~0.2.0",
"tiny-relative-date": "^1.3.0",
"uid-number": "0.0.6",
"umask": "~1.1.0",
"unique-filename": "~1.1.0",
"unpipe": "~1.0.0",
"update-notifier": "^2.5.0",
"uuid": "^3.3.2",
"validate-npm-package-license": "^3.0.4",
"validate-npm-package-name": "~3.0.0",
"which": "^1.3.1",
"worker-farm": "^1.6.0",
"write-file-atomic": "^2.3.0"
},
"bundleDependencies": [
"abbrev",
"ansicolors",
"ansistyles",
"aproba",
"archy",
"byte-size",
"cacache",
"call-limit",
"bluebird",
"bin-links",
"chownr",
"ci-info",
"cmd-shim",
"columnify",
"config-chain",
"debuglog",
"detect-indent",
"detect-newline",
"dezalgo",
"editor",
"figgy-pudding",
"find-npm-prefix",
"fs-vacuum",
"fs-write-stream-atomic",
"gentle-fs",
"glob",
"graceful-fs",
"has-unicode",
"hosted-git-info",
"iferr",
"imurmurhash",
"inflight",
"inherits",
"ini",
"init-package-json",
"is-cidr",
"json-parse-better-errors",
"JSONStream",
"lazy-property",
"libcipm",
"libnpmhook",
"libnpx",
"lockfile",
"lodash._baseindexof",
"lodash._baseuniq",
"lodash._bindcallback",
"lodash._cacheindexof",
"lodash._createcache",
"lodash._getnative",
"lodash.clonedeep",
"lodash.restparam",
"lodash.union",
"lodash.uniq",
"lodash.without",
"lru-cache",
"meant",
"mkdirp",
"mississippi",
"move-concurrently",
"nopt",
"normalize-package-data",
"npm-audit-report",
"npm-cache-filename",
"npm-lifecycle",
"npm-install-checks",
"npm-package-arg",
"npm-packlist",
"npm-pick-manifest",
"npm-profile",
"npm-registry-client",
"npm-registry-fetch",
"npm-user-validate",
"npmlog",
"once",
"opener",
"osenv",
"pacote",
"path-is-inside",
"promise-inflight",
"query-string",
"qrcode-terminal",
"qw",
"read",
"read-cmd-shim",
"read-installed",
"read-package-json",
"read-package-tree",
"readable-stream",
"readdir-scoped-modules",
"request",
"retry",
"rimraf",
"semver",
"sha",
"slide",
"sorted-object",
"sorted-union-stream",
"ssri",
"tar",
"text-table",
"uid-number",
"umask",
"unique-filename",
"unpipe",
"update-notifier",
"uuid",
"validate-npm-package-license",
"validate-npm-package-name",
"which",
"write-file-atomic",
"safe-buffer",
"worker-farm",
"tiny-relative-date",
"cli-columns",
"cli-table3",
"node-gyp",
"lock-verify",
"stringify-package"
],
"devDependencies": {
"deep-equal": "~1.0.1",
"marked": "^0.5.0",
"marked-man": "~0.2.1",
"npm-registry-couchapp": "^2.7.1",
"npm-registry-mock": "~1.1.0",
"require-inject": "^1.4.3",
"sprintf-js": "~1.1.1",
"standard": "^11.0.1",
"tacks": "^1.2.7",
"tap": "^12.0.1"
},
"scripts": {
"dumpconf": "env | grep npm | sort | uniq",
"prepare": "node bin/npm-cli.js --no-audit --no-timing prune --prefix=. --no-global && rimraf test/*/*/node_modules && make -j4 doc",
"preversion": "bash scripts/update-authors.sh && git add AUTHORS && git commit -m \"update AUTHORS\" || true",
"start": "node server.js",
"start:dev": "webpack-dev-server",
"tap": "tap --reporter=classic --timeout 300",
"tap-cover": "tap --reporter=classic --nyc-arg='--cache' --coverage --timeout 600",
"test": "standard && npm run test-tap",
"test-coverage": "npm run tap-cover -- \"test/tap/*.js\" \"test/network/*.js\" \"test/broken-under-*/*.js\"",
"test-tap": "npm run tap -- \"test/tap/*.js\" \"test/network/*.js\" \"test/broken-under-*/*.js\"",
"test-node": "tap --timeout 240 \"test/tap/*.js\" \"test/network/*.js\" \"test/broken-under-nyc*/*.js\""
},
"license": "Artistic-2.0"
}
答案 0 :(得分:0)
npm start
不起作用,因为您没有必需的依赖项。 跨环境:未找到 package.json
,以便我们定义真正的问题。回答您的问题
为什么要寻找packages / react-error-overlay /目录?
似乎您拥有postinstall
脚本。在此处阅读有关pre
和post
挂钩的更多信息:https://docs.npmjs.com/misc/scripts
P.S。在postinstall
中使用无效的package.json
脚本,您应该得到下一个错误:
error Failed at the test@1.0.0 postinstall script.
似乎您从name
表单中删除了version
和package.json
,这就是下一个错误的原因:
error Failed at the undefined postinstall script.
日志中的undefined
会让您感到困惑