我正在处理一个node + express + type-srcipt项目。我运行npm run build
时一切正常,但是运行npm run start
时出现此错误。
@ruler-mobility/ruler@1.0.0 start /Users/macbook/Desktop/ruler
> npm run serve
> @ruler-mobility/ruler@1.0.0 serve /Users/macbook/Desktop/ruler
> node dist/app.js
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ruler-mobility/ruler@1.0.0 serve: `node dist/app.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ruler-mobility/ruler@1.0.0 serve 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/macbook/.npm/_logs/2020-02-21T20_53_55_009Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ruler-mobility/ruler@1.0.0 start: `npm run serve`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ruler-mobility/ruler@1.0.0 start 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/macbook/.npm/_logs/2020-02-21T20_53_55_045Z-debug.log
注意:标尺是项目的名称。
我在packag.json中的脚本设置如下:
"scripts": {
"start": "npm run serve",
"build": "npm run build-source",
"serve": "node dist/app.js",
"watch-node": "nodemon dist/app.js",
"watch": "concurrently -k -p \"[{name}]\" -n \"TypeScript,Node\" -c \"cyan.bold,green.bold\" \"npm run watch-source\" \"npm run watch-node\"",
"build-source": "webpack",
"watch-source": "webpack -w",
"debug": "npm run build && npm run watch-debug",
"serve-debug": "nodemon --inspect dist/app.js",
"watch-debug": "concurrently -k -p \"[{name}]\" -n \"TypeScript,Node\" -c \"cyan.bold,green.bold\" \"npm run watch-source\" \"npm run serve-debug\"",
"lint": "eslint \"**/*.{js,jsx,ts,tsx}\" --quiet --fix",
"test": "jest --forceExit --coverage --verbose",
"watch-test": "npm run test -- --watchAll",
"stop-win": "Taskkill /IM node.exe /F",
"stop-linux": "killall node"
},
这是我的tscongfig.json文件:
{
"compilerOptions": {
"alwaysStrict": true,
"module": "commonjs",
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"jsx": "react",
"lib": ["es6", "dom"],
"target": "es6",
"noImplicitAny": true,
"moduleResolution": "node",
"sourceMap": true,
"outDir": "dist",
"baseUrl": ".",
"paths": {
"*": ["node_modules/*"],
"@ruler": ["src", "packages"],
"@ruler/*": ["src/*", "packages/*"],
"@ruler/configs": ["configs"],
"@ruler/configs/*": ["configs/*"],
"@ruler/test": ["test"],
"@ruler/test/*": ["test/*"],
"@ruler/types": ["types"],
"@ruler/types/*": ["types/*"]
}
},
"exclude": ["node_modules", "**/*.spec.ts"]
}
我是打字稿的开始者,有人可以告诉我如何运行我的项目吗?
谢谢。
答案 0 :(得分:0)
看来问题出在webpack构建项目的位置。如果删除dist
并运行npm run build
,然后检查dist
是否存在,这将告诉您构建任务是否将输出放入dist
。