たのしい工学

プログラミングを学んで、モノをつくりたいひと、効率的に仕事をしたい人のための硬派なブログになりました

[mac TypeScript] npm start permission deniedエラーの対処法

   

TypeScriptで書いたアプリケーションをGitHubからmacの環境にCloneしてきて、npm startしたときに下記のようなエラーが出た場合

ts_tutorial@1.0.0 start /Users/syu/typescript-sandbox/ts_tutorial
webpack-dev-server --mode=development
sh: /Users/shuji/typescript-sandbox/ts_tutorial/node_modules/.bin/webpack-dev-server: Permission denied
npm ERR! code ELIFECYCLE
npm ERR! errno 126
npm ERR! ts_tutorial@1.0.0 start: webpack-dev-server --mode=development
npm ERR! Exit status 126
npm ERR!
npm ERR! Failed at the ts_tutorial@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/shuji/.npm/_logs/2020-09-08T08_17_40_851Z-debug.log

ほとんどの場合は、ノードのインストールが悪いか、他のプロジェクトからコピー&ペーストしているモジュールに関連しているかもしれません。やるべきことはnodeの再インストールです。

brew uninstall node

node_modulesディレクトリを削除

Nodeをgloballyでインストールする

brew install -g node
npm install
npm start

これでエラーは解消されるはずです。

 - プログラミング系 , , ,