Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot find module requirejs when installed globally

I have installed requirejs globally, but node says it can't find it.

# node tools/mapconv.js

module.js:340
    throw err;
          ^
Error: Cannot find module 'requirejs'
    ...

# cat mapconv.js
var requirejs = require('requirejs');
...

The module is definitely installed:

# npm ls -g | grep requirejs
├── [email protected]

I have cleared the NPM cache, but no change. Has anyone else run into this?

like image 372
alekop Avatar asked Jun 23 '13 19:06

alekop


People also ask

Can not find module npm?

Set the Windows environment variable for NODE_PATH. This path is where your packages are installed. It's probably something likeNODE_PATH = C:\Users\user\node_modules or C:\Users\user\AppData\Roaming\npm\node_modules. Start a new cmd console and npm should work fine.

Can not find module Cors?

To solve the error "Cannot find module 'cors'", make sure to install the cors package by opening your terminal in your project's root directory and running the following command: npm i cors . If you use TypeScript, install the typings by running npm i -D @types/cors . Here is an example of how the error occurs.


1 Answers

Make sure your NODE_PATH environment variable is set. To find out where to set it to, run:

npm install --global --verbose requirejs

set node path to the dir ending in node_modules

like image 167
Lyn Headley Avatar answered Oct 05 '22 02:10

Lyn Headley