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
2
votes
0 answers

How to deal with require() files inside a node_module?

I am quite new to node_moduels. For instance, say you have this structure: The app directory your_app/node_modules/your_module your_app/app.js The module directory your_module/index.js lib/a_file_you_require_in_index.js When you require the file…
ole-jorgen
  • 21
  • 3
2
votes
0 answers

returning a value from node-fetch

exports.img = function(){ fetch("http://aws.random.cat/meow") .then(res => res.json()) .then(json => console.log(json.file)); } I have been trying to return the "file" value from the json i fetched but I keep either producing "promise { }"…
2
votes
0 answers

overrideProvider(token) not working in nestJS for Test.createTestingModule

I'm having a problem with overriding a provider in a test context. I know I'm missing something blindingly obvious, but I've tried loads of permutations and none have worked, so I'm putting this out to the hive mind. I have the following…
EricP
  • 173
  • 2
  • 14
2
votes
0 answers

How to change NODE_PATH dynamically?

In my mocha tests I want to require files from the ./lib folder without specifying relative path to a required file. Instead of require('../../../lib/folder/file') I want to require('folder/file') I was able to achieve this with…
Hirurg103
  • 4,783
  • 2
  • 34
  • 50
2
votes
0 answers

How to add multiple images to single tiff in nodejs?

var ConvertTiff = require('tiff-to-png'), converter = new ConvertTiff(); var filePath = __dirname + '\\tifffile\\mytifffile.tiff'; var filePAth1=__dirname + '\\images\\abc1.tiff'; var filePAth2=__dirname + '\\images\\abc1.tiff'; var tiffs…
Aadi
  • 1,131
  • 2
  • 16
  • 32
2
votes
1 answer

Import node modules from priv/static/js folder in Phoenix 1.4

I installed vuejs with a npm install in my assets/ folder and I created a list_show.js file in priv/static/js/list_show.js . When I do import Vue from "vue" in my list_show.js, it doesn't work and I get this message in the console: "Uncaught…
popo63301
  • 509
  • 1
  • 4
  • 10
2
votes
0 answers

Docker tar not found on nvm install node step

I'm trying to create a Docker container running node.js on Amazon Linux to allow native node modules to compile on machine in a suitable form for AWS Lambda. I'm primarily following this tutorial on The Polyglot Developer, but have also tried one on…
Josh
  • 1,517
  • 1
  • 13
  • 21
2
votes
3 answers

npm ENOENT no such file or directory, open {path}/package.json

I followed this tutorial for Modular programming in nodejs. https://dzone.com/articles/build-your-nodejs-application-in-a-modular-way I've hard links to specified dependencies under node_modules…
Developer
  • 924
  • 3
  • 14
  • 30
2
votes
2 answers

How to tell npm to not to install any dependency when somebody installs my npm module?

I have created an NPM module which is already built and published. so when somebody installs it, my module doesn't really need any extra dependency to work properly as it is already built. However, the current behavior is that when I install my…
Sivasankar
  • 753
  • 8
  • 22
2
votes
1 answer

VSCode + Typescript in dockerized React app

I'm running typescript with create-react-app on a local machine for development purposes. I've gotten rid of the node_modules directory as it's not needed once my image installs the dependencies. The app is able to run when I start it, but I want to…
Grant
  • 121
  • 5
2
votes
2 answers

Exposing external module TypeScript declarations to consuming modules

I have a published TypeScript module (let's call it shared-stuff) that is designed to be imported by other TypeScript modules. This shared-stuff module has third-party dependencies that have no @types-scoped declarations, so inside of that module…
Jacob
  • 77,566
  • 24
  • 149
  • 228
2
votes
0 answers

Dynamic-Imports via babel-register resulting in surplus "default module"

I have (polymorphic) code that is bundled using webpack including dynamic-imports (for code-splitting) and want to run the same code in NodeJS, currently using babel-register to be able to run the ES6 code. I've encountered an issue when it comes to…
Tobias K.
  • 2,997
  • 2
  • 12
  • 29
2
votes
2 answers

Expected argument to be of type `array` but received type `string` - image-webpack-loader

I'm using image-webpack-loader but I got this error message: I import my images like this: import icon10 from '../../assets/img/icon10.png'; ERROR in ./app/assets/img/icon10.png Module build failed (from…
S.M_Emamian
  • 17,005
  • 37
  • 135
  • 254
2
votes
0 answers

Angular External Style in Angular.json or Styles.scss

I want to include an external style from a module in node_modules. Which is considered better practice? Add the stylesheet to Angular.json in the application's build: styles: [], e.g. "build": { "styles": [ ..., …
tgordon18
  • 1,562
  • 1
  • 19
  • 31
2
votes
1 answer

Angular universal - warning while running node.js

I have angular 7 site - which I have converted into server side rendering (referring mainly https://blog.angular-university.io/angular-universal/). I am running site on AWS using 'foreever'. I aways see below error inside my foreever error log…
user2869612
  • 607
  • 2
  • 10
  • 32