alexjoverm / typescript-library-starter

Starter kit with zero-config for building a library in TypeScript, featuring RollupJS, Jest, Prettier, TSLint, Semantic Release, and more!
MIT License
4.37k stars 493 forks source link

ts-node tools/init failed while initializing the project under windows 10 #300

Closed wiekern closed 4 years ago

wiekern commented 5 years ago

OS: Win 10 node: v8.15.1 npm: 6.4.1

> ts-node tools/init

Hi! You're almost ready to make the next great TypeScript library.

Would you like it to be called "typescript-axios"? [Yes/No]:  yes

Thanks for the info. The last few changes are being made... hang tight!

AzureAD\xxx

xxx@gmail.com

Removed

.git

.all-contributorsrc

.gitattributes

tools/init.ts

Modified

LICENSE

package.json

rollup.config.ts

test/library.test.ts

tools/gh-pages-publish.ts

Renamed

src/library.ts => src/typescript-axios.ts

test/library.test.ts => test/typescript-axios.test.ts

Finalizing

Initialized empty Git repository in C:/Users/xxx/Desktop/typescript-axios/.git/

C:\Users\xxx\Desktop\typescript-axios\tools\init.ts:264

  const pkg = JSON.parse(readFileSync(jsonPackage) as any)

                   ^

SyntaxError: Unexpected token Y in JSON at position 289

    at JSON.parse (<anonymous>)

    at finalize (C:\Users\xxx\Desktop\typescript-axios\tools\init.ts:264:20)

    at setupLibrary (C:\Users\xxx\Desktop\typescript-axios\tools\init.ts:183:3)

    at C:\Users\xxx\Desktop\typescript-axios\tools\init.ts:124:7

    at C:\Users\xxx\Desktop\typescript-axios\node_modules\prompt\lib\prompt.js:336:32

    at C:\Users\xxx\Desktop\typescript-axios\node_modules\utile\node_modules\async\lib\async.js:154:25

    at assembler (C:\Users\xxx\Desktop\typescript-axios\node_modules\prompt\lib\prompt.js:333:9)

    at C:\Users\xxx\Desktop\typescript-axios\node_modules\prompt\lib\prompt.js:342:32

    at C:\Users\xxx\Desktop\typescript-axios\node_modules\prompt\lib\prompt.js:625:5

    at Interface.onLine (C:\Users\xxx\Desktop\typescript-axios\node_modules\read\lib\read.js:111:5)

npm ERR! code ELIFECYCLE

npm ERR! errno 1

npm ERR! --libraryname--@0.0.0 postinstall: `ts-node tools/init`

npm ERR! Exit status 1

npm ERR!

npm ERR! Failed at the --libraryname--@0.0.0 postinstall 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!     C:\Users\xxx\AppData\Roaming\npm-cache\_logs\2019-06-25T19_52_31_495Z-debug.log

In this situation, the git username extracted by the command git config user.name is " AzureAD\xxx", in which there is a prefix "AzureAD\" including a back slash. This leads to a misformed package.json file due to the back slash in the field of "author". To solve this error, you can set the git username globally by git config --global user.name "USERNAME", then everything will be fine..