댓글 검색 목록

[Nodejs] npm-name - npm에 패키지 이름을 사용할 수 있는지 확인합니다.

페이지 정보

작성자 운영자 작성일 19-03-07 00:43 조회 511 댓글 0

https://github.com/sindresorhus/npm-name

npm에서 패키지 이름을 사용할 수 있는지 확인하십시오.


const npmName = require('npm-name');

(async () => {
	console.log(await npmName('chalk'));
	//=> false

	const result = await npmName.many(['chalk', '@sindresorhus/is', 'abc123']);
	console.log(result.get('chalk'));
	//=> false
	console.log(result.get('@sindresorhus/is'));
	//=> false
	console.log(result.get('abc123'));
	//=> true

	try {
		await npmName('_ABC');
	} catch (error) {
		console.log(error.message);
		// Invalid package name: _ABC
		// - name cannot start with an underscore
		// - name can no longer contain capital letters
	}
})();

댓글목록 0

등록된 댓글이 없습니다.

웹학교 로고

온라인 코딩학교

코리아뉴스 2001 - , All right reserved.