尝试将Loopback用于新项目(对此进行决定),并且按照the docs page中所述的步骤操作后,我立即收到此错误消息:
Found 12 errors.
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! [email protected] build: `tsc --outDir dist --target es2017`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the [email protected] 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! /Users/aa/.npm/_logs/2019-02-06T16_44_39_286Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! [email protected] prepare: `npm run build`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the [email protected] prepare 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! /Users/aa/.npm/_logs/2019-02-06T16_44_39_349Z-debug.log
Application start was created in start.`
知道这是什么意思,我该如何解决?
对于错误最后一部分中提到的日志,以下是其相关行:
7676 silly install [email protected]
7677 info lifecycle [email protected]~install: [email protected]
7678 silly postinstall [email protected]
7679 info lifecycle [email protected]~postinstall: [email protected]
7680 silly prepublish [email protected]
7681 info lifecycle [email protected]~prepublish: [email protected]
7682 info lifecycle [email protected]~prepare: [email protected]
7683 verbose lifecycle [email protected]~prepare: unsafe-perm in lifecycle true
7684 verbose lifecycle [email protected]~prepare: PATH: /Users/aa/.nvm/versions/node/v10.14.1/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/aa/Documents/loopback-test-app/trial/start/node_modules/.bin:/Library/Frameworks/Python.framework/Versions/3.7/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/opt/local/bin:/opt/local/sbin:/Users/aa/.nvm/versions/node/v10.14.1/bin:/Users/aa/go/bin:/data/mongo/bin:/Users/aa/Users/aa/npm/lib/node_modules/strapi:/Users/aa/.npm-packages/bin:/Users/g/Library/Haskell/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications:/usr/local/go/bin:/Applications/Postgres.app/Contents/Versions/latest/bin
7685 verbose lifecycle [email protected]~prepare: CWD: /Users/aa/Documents/loopback-test-app/trial/start
7686 silly lifecycle [email protected]~prepare: Args: [ '-c', 'npm run build' ]
7687 silly lifecycle [email protected]~prepare: Returned: code: 2 signal: null
7688 info lifecycle [email protected]~prepare: Failed to exec prepare script
7689 verbose stack Error: [email protected] prepare: `npm run build`
7689 verbose stack Exit status 2
7689 verbose stack at EventEmitter.<anonymous> (/Users/aa/.nvm/versions/node/v10.14.1/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:301:16)
7689 verbose stack at EventEmitter.emit (events.js:182:13)
7689 verbose stack at ChildProcess.<anonymous> (/Users/aa/.nvm/versions/node/v10.14.1/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
7689 verbose stack at ChildProcess.emit (events.js:182:13)
7689 verbose stack at maybeClose (internal/child_process.js:962:16)
7689 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:251:5)
7690 verbose pkgid [email protected]
7691 verbose cwd /Users/aa/Documents/loopback-test-app/trial/start
7692 verbose Darwin 18.2.0
7693 verbose argv "/Users/aa/.nvm/versions/node/v10.14.1/bin/node" "/Users/aa/.nvm/versions/node/v10.14.1/bin/npm" "install" "--cache-min" "86400"
7694 verbose node v10.14.1
7695 verbose npm v6.4.1
7696 error code ELIFECYCLE
7697 error errno 2
7698 error [email protected] prepare: `npm run build`
7698 error Exit status 2
7699 error Failed at the [email protected] prepare script.
7699 error This is probably not a problem with npm. There is likely additional logging output above.
7700 verbose exit [ 2, true ]
最佳答案
事实证明,由于未知原因,Loopback 4并未安装Typescript所需的Mocha类型。我进入应用程序的根文件夹,并使用npm install @types/mocha
安装它。现在可以了。
关于node.js - Loopback 4项目开箱即用返回构建错误(errno 2),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/54558723/