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?
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With