node -v => v8.9.4
npm -v => 5.6.0
想要安装this示例 例子中有一个错误或我做错了什么? 我相信安装示例所有你需要做的就是克隆并运行npm install但是在执行之后:
mkdir test
cd test
git clone https://github.com/palmerhq/backpack.git
cd ./backpack/examples/with-typescript/
npm install
npm run dev
我收到了:
| backpack-examples-with-typescript@0.5.0 dev ~/test/backpack/examples/with-typescript
| backpack dev
[at-loader] Using typescript@2.7.1 from typescript and "tsconfig.json" from ~/test/backpack/examples/with-typescript/tsconfig.json.
[at-loader] Checking started in a separate process...
[at-loader] Checking finished with 1 errors
ERROR Failed to compile with 1 errors 19:38:08
error
加号
[at-loader] ./src/main.ts:33:35
TS2322: Type 'string | 3000' is not assignable to type 'number'.
Type 'string' is not assignable to type 'number'.
module.js:540
throw err;
^
Error: Cannot find module '~/test/backpack/examples/with-typescript/build/main.js'
at Function.Module._resolveFilename (module.js:538:15)
at Function.Module._load (module.js:468:25)
at Function.Module.runMain (module.js:684:10)
at startup (bootstrap_node.js:187:16)
at bootstrap_node.js:608:3
我在几天前的问题上写了this question,但没有人回答
答案 0 :(得分:1)
源代码的this line (33:35)出错了。 NodeJS类型声明中process.env.PORT
是typed as string。 getPort
但必须返回一个数字。尝试使用以下内容更改该行:
private getPort = (): number => parseInt(process.env.PORT) || 3000;
由于at-loader
无法编译,因此无法找到无法找到js文件的附加错误,因此它没有输出该文件。