Quantcast
Channel: Node.jsタグが付けられた新着記事 - Qiita
Viewing all articles
Browse latest Browse all 8868

Cannot find module 'express'の解決法

$
0
0

nodeをインストールしてプログラムを実行しようとした所、エラーが出た。

エラー文

internal/modules/cjs/loader.js:834
  throw err;
  ^

Error: Cannot find module 'express'

プログラム

app.js
constexpress=require('express')constapp=express()constport=3000app.get('/',(req,res)=>{res.send('Hello World!')})app.listen(port,()=>{console.log(`Example app listening at http://localhost:${port}`)})

https://expressjs.com/ja/starter/hello-world.html

対処方法

expressをinstallし、パスを通す。
oh、簡単。。。

$ npm install -g express
$ export NODE_PATH=/usr/local/lib/node_modules

参考

Nodeでnode_modulesにパスを通す


Viewing all articles
Browse latest Browse all 8868

Trending Articles