thi-ng / create-hdom-app

New project generator for @thi.ng/hdom TypeScript apps
16 stars 3 forks source link

add @types/node package to support `process.env` #1

Closed 100ideas closed 6 years ago

100ideas commented 6 years ago

yarn create hdom-app (v0.3.0) produces a default project scaffold that leads to a typescript compile error. Type definitions for node are not included so the ts compiler chokes on the reference to process.env.NODE_ENV in index.ts.

One solution is to add @types/node to package.json devDependencies. Not sure if that's overkill or if there is another preferred way of setting up the environment around the output of create-hdom-app. Maybe most people already have node ts type definitions installed globally?

Thanks so much for this fantastic collection of packages! I am becoming a better programmer thanks to the excellent documentation, examples, and modularity of your "umbrella" project.

error:

[tsl] ERROR in /Users/100ideas/dev/hdom/1_helloworld/src/index.ts(6,5)
      TS2304: Cannot find name 'process'.

log:

❯ yarn create hdom-app 1_helloworld
yarn create v1.5.1
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 📃  Building fresh packages...
success Installed "create-hdom-app@0.3.0" with binaries:
      - create-hdom-app
[##################] 18/18Creating a new app "1_helloworld" in /Users/100ideas/dev/hdom/1_helloworld...
...

❯ cd 1_helloworld && yarn start
yarn run v1.5.1
$ webpack-dev-server --hot --open --mode development --devtool inline-source-map
ℹ 「wds」: Project is running at http://localhost:8080/
ℹ 「wds」: webpack output is served from /
ℹ 「wds」: Content not from webpack is served from public
ℹ 「wdm」: wait until bundle finished: /
✖ 「wdm」: Hash: 10cb48300d19dfe5a9cd
Version: webpack 4.5.0
Time: 1819ms
Built at: 4/6/2018 3:50:53 AM
    Asset      Size  Chunks             Chunk Names
bundle.js  1.12 MiB    main  [emitted]  main
Entrypoint main = bundle.js
[./node_modules/loglevel/lib/loglevel.js] 7.68 KiB {main} [built]
[./node_modules/strip-ansi/index.js] 161 bytes {main} [built]
[./node_modules/url/url.js] 22.8 KiB {main} [built]
[./node_modules/webpack-dev-server/client/index.js?http://localhost:8080] (webpack)-dev-server/client?http://localhost:8080 7.75 KiB {main} [built]
[./node_modules/webpack-dev-server/client/overlay.js] (webpack)-dev-server/client/overlay.js 3.58 KiB {main} [built]
[./node_modules/webpack-dev-server/client/socket.js] (webpack)-dev-server/client/socket.js 1.05 KiB {main} [built]
[./node_modules/webpack/hot sync ^\.\/log$] (webpack)/hot sync nonrecursive ^\.\/log$ 170 bytes {main} [built]
[./node_modules/webpack/hot/dev-server.js] (webpack)/hot/dev-server.js 1.66 KiB {main} [built]
[./node_modules/webpack/hot/emitter.js] (webpack)/hot/emitter.js 77 bytes {main} [built]
[./node_modules/webpack/hot/log-apply-result.js] (webpack)/hot/log-apply-result.js 1.31 KiB {main} [built]
[./node_modules/webpack/hot/log.js] (webpack)/hot/log.js 1.03 KiB {main} [built]
[./src/app.ts] 3.35 KiB {main} [built]
   [0] multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-server ./src/index.ts 52 bytes {main} [built]
[./src/config.ts] 4.38 KiB {main} [built]
[./src/index.ts] 392 bytes {main} [built] [1 error]
    + 57 hidden modules

ERROR in /Users/100ideas/dev/hdom/1_helloworld/src/index.ts
./src/index.ts
[tsl] ERROR in /Users/100ideas/dev/hdom/1_helloworld/src/index.ts(6,5)
      TS2304: Cannot find name 'process'.
ℹ 「wdm」: Failed to compile.
^C⏎

~/dev/hdom/1_helloworld
❯ yarn add -D @types/node   
yarn add v1.5.1
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 📃  Building fresh packages...
success Saved lockfile.
success Saved 1 new dependency.
info Direct dependencies
└─ @types/node@9.6.2
info All dependencies
└─ @types/node@9.6.2
✨  Done in 3.32s.

~/dev/hdom/1_helloworld 
❯ yarn start            
yarn run v1.5.1
$ webpack-dev-server --hot --open --mode development --devtool inline-source-map
ℹ 「wds」: Project is running at http://localhost:8080/
ℹ 「wds」: webpack output is served from /
ℹ 「wds」: Content not from webpack is served from public
ℹ 「wdm」: wait until bundle finished: /
ℹ 「wdm」: Hash: 5b5f1821623d6ea68f60
Version: webpack 4.5.0
Time: 1970ms
Built at: 4/6/2018 3:57:08 AM
    Asset      Size  Chunks             Chunk Names
bundle.js  1.12 MiB    main  [emitted]  main
Entrypoint main = bundle.js
[./node_modules/loglevel/lib/loglevel.js] 7.68 KiB {main} [built]
[./node_modules/strip-ansi/index.js] 161 bytes {main} [built]
[./node_modules/url/url.js] 22.8 KiB {main} [built]
[./node_modules/webpack-dev-server/client/index.js?http://localhost:8080] (webpack)-dev-server/client?http://localhost:8080 7.75 KiB {main} [built]
[./node_modules/webpack-dev-server/client/overlay.js] (webpack)-dev-server/client/overlay.js 3.58 KiB {main} [built]
[./node_modules/webpack-dev-server/client/socket.js] (webpack)-dev-server/client/socket.js 1.05 KiB {main} [built]
[./node_modules/webpack/hot sync ^\.\/log$] (webpack)/hot sync nonrecursive ^\.\/log$ 170 bytes {main} [built]
[./node_modules/webpack/hot/dev-server.js] (webpack)/hot/dev-server.js 1.66 KiB {main} [built]
[./node_modules/webpack/hot/emitter.js] (webpack)/hot/emitter.js 77 bytes {main} [built]
[./node_modules/webpack/hot/log-apply-result.js] (webpack)/hot/log-apply-result.js 1.31 KiB {main} [built]
[./node_modules/webpack/hot/log.js] (webpack)/hot/log.js 1.03 KiB {main} [built]
[./src/app.ts] 3.35 KiB {main} [built]
   [0] multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-server ./src/index.ts 52 bytes {main} [built]
[./src/config.ts] 4.38 KiB {main} [built]
[./src/index.ts] 392 bytes {main} [built]
    + 57 hidden modules
ℹ 「wdm」: Compiled successfully.
^C⏎
postspectacular commented 6 years ago

Oh thanks!!! :) This is really weird though, since I'm not getting any errors and building all possible combinations before pushing a new release. Maybe I've got those node typedefs installed globally, not sure, but will add it pronto... :)