Questions tagged [node-modules]

Node.js has a simple module loading system that reduces complexity of applications and promotes code reusability.

Node.js has a simple module loading system that reduces complexity of applications and promotes code reusability. In Node.js, files and modules are in one-to-one correspondence.

For example, foo.js loads the module circle.js in the same directory:

The contents of foo.js:

var circle = require('./circle.js');
console.log( 'The area of a circle of radius 4 is ' + circle.area(4));

The contents of circle.js:

var PI = Math.PI;

exports.area = function (r) {
  return PI * r * r;
};

exports.circumference = function (r) {
  return 2 * PI * r;
};

Node.js also has an incredible community of open source developers who publish packages using :

6621 questions
2104
votes
65 answers

How can I update Node.js and NPM to their latest versions?

I just installed Node.js and NPM (Node Package Manager). I installed NPM for access to additional Node.js modules. After I installed Node.js and NPM, I noticed that neither were the latest versions available. How do I upgrade Node.js, NPM, and my…
Dail
  • 21,261
  • 3
  • 16
  • 5
1199
votes
22 answers

How to install an npm package from GitHub directly

Trying to install modules from GitHub results in this error: ENOENT error on package.json. Easily reproduced using express: npm install https://github.com/visionmedia/express throws error. npm install express works. Why can't I install from…
guy mograbi
  • 27,391
  • 16
  • 83
  • 122
955
votes
38 answers

Could not find a declaration file for module 'module-name'. '/path/to/module-name.js' implicitly has an 'any' type

I read how TypeScript module resolution works. I have the following repository: @ts-stack/di. After compiling the directory structure is as follows: ├── dist │   ├── annotations.d.ts │   ├── annotations.js │   ├── index.d.ts │   ├── index.js │   ├──…
ktretyak
  • 27,251
  • 11
  • 40
  • 63
719
votes
25 answers

How to use executables from a package installed locally in node_modules?

How do I use a local version of a module in node.js. For example, in my app, I installed coffee-script: npm install coffee-script This installs it in ./node_modules and the coffee command is in ./node_modules/.bin/coffee. Is there a way to run this…
typeoneerror
  • 55,990
  • 32
  • 132
  • 223
660
votes
18 answers

Git - Ignore node_modules folder everywhere

I have a project containing multiple other projects : Main project Mini project 1 Mini project 2 All containing node_modules folder. I want git to ignore the folder no matter where it is starting from the root folder. Something like this to…
Mehdiway
  • 10,337
  • 8
  • 36
  • 68
620
votes
32 answers

SyntaxError: Cannot use import statement outside a module

I've got an ApolloServer project that's giving me trouble, so I thought I might update it and ran into issues when using the latest Babel. My "index.js" is: require('dotenv').config() import {startServer} from './server' startServer() And when I…
user3810626
  • 6,798
  • 3
  • 14
  • 19
380
votes
20 answers

How to use paths in tsconfig.json?

I was reading about path-mapping in tsconfig.json and I wanted to use it to avoid using the following ugly paths: The project organization is a bit weird because we have a mono-repository that contains projects and libraries. The projects are…
Remo H. Jansen
  • 23,172
  • 11
  • 70
  • 93
358
votes
22 answers

Cannot install NodeJs: /usr/bin/env: node: No such file or directory

I'm trying to install nodeJs into my Ubuntu 14.04 in order to use GruntJs. I've read about Ubuntu different way of doing it (issues?), so this is what I've done in order to install it: sudo apt-get install npm sudo npm install -g grunt-cli Typing…
Rosamunda
  • 14,620
  • 10
  • 40
  • 70
349
votes
12 answers

How to include scripts located inside the node_modules folder?

I have a question concerning best practice for including node_modules into a HTML website. Imagine I have Bootstrap inside my node_modules folder. Now for the production version of the website, how would I include the Bootstrap script and CSS files…
Chris
  • 6,093
  • 11
  • 42
  • 55
318
votes
12 answers

Delete node_modules folder recursively from a specified path using command line

I have multiple npm projects saved in a local directory. Now I want to take backup of my projects without the node_modules folder, as it is taking a lot of space and can also be retrieved any time using npm install. So, what would be a solution to…
Sumit
  • 3,652
  • 4
  • 13
  • 19
234
votes
3 answers

What are differences between SystemJS and Webpack?

I'm creating my first Angular application and I would figure out what is the role of the module loaders. Why we need them? I tried to search and search on Google and I can't understand why we need to install one of them to run our…
smartmouse
  • 13,912
  • 34
  • 100
  • 166
219
votes
28 answers

Node - was compiled against a different Node.js version using NODE_MODULE_VERSION 51

I am running a node application on terminal. Have recently upgraded to node v8.5.0, but am getting this error: Error: The module '/tidee/tidee-au/packages/tidee-au-server/node_modules/bcrypt/lib/binding/bcrypt_lib.node' was compiled against a…
JoeTidee
  • 24,754
  • 25
  • 104
  • 149
217
votes
4 answers

npm: When to use `--force` and `--legacy-peer-deps`

I'm trying to understand how recreating the node_modules directory for deployment works. We're using npm ci instead of npm install to ensure a clean slate during deployment. However, when we run it without any flags, we get the following error: Fix…
Floating Sunfish
  • 4,920
  • 5
  • 29
  • 48
202
votes
6 answers

Npm install failed with "cannot run in wd"

I am trying to get my node environment set up on a new Ubuntu 12.04 instance, with Node 0.8.14 already installed, but I ran into problems when I try to run npm install. So when I try npm install, it says that I need to run it as root or…
E.H.
  • 3,271
  • 4
  • 19
  • 18
175
votes
17 answers

npm WARN enoent ENOENT: no such file or directory, open 'C:\Users\Nuwanst\package.json'

I just want to install socket.io to my project which is located on 3.chat folder. But when I run following command it shows following Warnings.And its not created a node_modules directory inside my project folder. How to fix…
user8109089
1
2 3
99 100