Problems running npm with node to increase memory - node.js

I have an Ubuntu docker container that has npm installed using nvm. In order to compile my code I am trying to run:
node --max_old_space_size=4096 npm run build
But I get:
root#faf3418e77d0:/myproject# node --max_old_space_size=4096 npm run build
module.js:538
throw err;
^
Error: Cannot find module '/myproject/npm'
at Function.Module._resolveFilename (module.js:536:15)
at Function.Module._load (module.js:466:25)
at Function.Module.runMain (module.js:676:10)
at startup (bootstrap_node.js:187:16)
at bootstrap_node.js:608:3
root#faf3418e77d0:/myproject#
I have npm so I do not understand how this is happening. I can run npm from any folder at my docker container. Any ideas?

Using the command: which npm
I found where it is located and used that complete info in my script.
Thx

Related

Module not found (MODULE_NOT_FOUND) on nest.js code base

I have a code base which is working perfectly fine on a Windows box on node v10.16.3 but when I try to install the same code base on a CentOS Linux box with node v.12.16.3, I get the following error. Not sure what the issue could be.
# npm start
> nest start
internal/modules/cjs/loader.js:960
throw err;
^
Error: Cannot find module '#angular-devkit/core'
Require stack:
- /usr/local/lib/node_modules/#nestjs/cli/lib/schematics/schematic.option.js
- /usr/local/lib/node_modules/#nestjs/cli/lib/schematics/index.js
- /usr/local/lib/node_modules/#nestjs/cli/actions/generate.action.js
- /usr/local/lib/node_modules/#nestjs/cli/actions/index.js
- /usr/local/lib/node_modules/#nestjs/cli/commands/command.loader.js
- /usr/local/lib/node_modules/#nestjs/cli/commands/index.js
- /usr/local/lib/node_modules/#nestjs/cli/bin/nest.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:957:15)
at Function.Module._load (internal/modules/cjs/loader.js:840:27)
at Module.require (internal/modules/cjs/loader.js:1019:19)
at require (internal/modules/cjs/helpers.js:77:18)
at Object.<anonymous>
(/usr/local/lib/node_modules/#nestjs/cli/lib/schematics/schematic.option.js:3:16)
at Module._compile (internal/modules/cjs/loader.js:1133:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
at Module.load (internal/modules/cjs/loader.js:977:32)
at Function.Module._load (internal/modules/cjs/loader.js:877:14)
at Module.require (internal/modules/cjs/loader.js:1019:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/usr/local/lib/node_modules/#nestjs/cli/lib/schematics/schematic.option.js',
'/usr/local/lib/node_modules/#nestjs/cli/lib/schematics/index.js',
'/usr/local/lib/node_modules/#nestjs/cli/actions/generate.action.js',
'/usr/local/lib/node_modules/#nestjs/cli/actions/index.js',
'/usr/local/lib/node_modules/#nestjs/cli/commands/command.loader.js',
'/usr/local/lib/node_modules/#nestjs/cli/commands/index.js',
'/usr/local/lib/node_modules/#nestjs/cli/bin/nest.js'
]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! Exit status 1
npm ERR!
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2020-05-22T14_14_24_709Z-debug.log
Delete the dist folder and again run yarn start, npm start, yarn start:dev or npm run start:dev to rebuild the dist folder. In addition yarn prebuild or npm run prebuild does the same thing using rimraf
The problem occurs when you change a name and the tsc does not change it in dist and transpiled .js files, so it cannot find the module
I think to the best of my knowledge, nestjs or tsc does that to make the transpilation faster
Nothing else worked for me but the following did:
npm install --save-dev webpack
i'm not completely sure if there is any adverse impact to this though
most important where you started node js the dist/ or / build folder has a worng path which we import or required so for
NPM : npm install --save-dev webpack
and for yarn add webpack this one packeg will slove your problem

Running yarn scripts in WebStorm with non-system node binary

I'm attempting to use WebStorm for a new project and use yarn instead of npm. However, after generating the project I can't get the scripts to run via yarn. My start script has the following run configuration in WebStorm.
package.json: ~/dev/starting_sandbox/package.json
Command: run
Scripts: start
Node Interpreter: ~/.nvm/versions/node/v7.8.0/bin/node
Npm package: ~/.nvm/versions/node/v7.8.0/lib/node_modules/yarn
When this runs I get an error:
/Users/byronsm/.nvm/versions/node/v7.8.0/bin/node /Users/byronsm/.nvm/versions/node/v7.8.0/lib/node_modules/yarn/bin/yarn.js run start
yarn run v0.21.3
$ react-scripts start
~/dev/starting_sandbox/node_modules/cross-spawn/index.js:34
throw new Error(
^
Error: In order to use spawnSync on node 0.10 or older, you must install spawn-sync:
npm install spawn-sync --save
at Function.spawnSync [as sync] (~/dev/starting_sandbox/node_modules/cross-spawn/index.js:34:19)
at Object.<anonymous> (~/dev/starting_sandbox/node_modules/react-scripts/bin/react-scripts.js:22:22)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:929:3
error Command failed with exit code 8.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
I was able to solve this problem in webpack when running the scripts via npm by using the --scripts-prepend-node-path option. However, this doesn't seem to exist for yarn.
This seems to be an issue with the instance of node that yarn runs when executing the scripts, instead of pulling from the same node binary used to execute yarn itself, it uses what it finds in $PATH, which isn't modified.
Is there a similar command you can use for yarn?

Git bash though error while run npm packages

While I am running any project in my git bash it's showing the following error:
ionic -v
module.js:471
throw err;
^
Error: Cannot find module 'C:\Program Files\Git\node_modules\ionic\bin\ionic'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:394:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:509:3
So I am not able to run the project and also it create a sh.exe.stackdump file in my project. I am not sure what the problem is. Please anyone help to find out the solution.
After cloning a repo you should run :
npm install
in your git root folder to install npm dependencies before being able to run the app.

Node Sass could not find a binding for your current environment: Linux 32-bit with Node.js 4.x

I am running a npm run build and get the following error
Node Sass could not find a binding for your current environment: Linux 32-bit with Node.js 4.x
Found bindings for the following environments:
- Windows 64-bit with Node.js 6.x
So i am doing npm rebuild node-sass and it gave the error
> node-sass#3.10.1 install /root/PokemonGo-Map/node_modules/node-sass
> node scripts/install.js
module.js:327
throw err;
^
Error: Cannot find module '/root/PokemonGo-Map/node_modules/node-sass/scripts/install.js'
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at Function.Module.runMain (module.js:441:10)
at startup (node.js:139:18)
at node.js:968:3
Any one can tell me what is the problem?

npm install -g cordova, npm install -g ionic on Windows10

I was trying to do push notifications using angular and ionic, i was getting few issues while i was running Command prompt.
So i had to uninstall node.js and i tried to re-install the node.js , it installed successfully as i verified by node -v then it showed me v4.4.2
Then i tried to install cordova, ionic by using following commands:
npm install -g cordova
npm install -g ionic
it throwed following errors:
module.js:327
throw err;
^
Error: Cannot find module 'C:\Program Files\nodejs\node_modules\npm\bin\node_modules\npm\bin\npm-cli.js'
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at Function.Module.runMain (module.js:441:10)
at startup (node.js:139:18)
at node.js:968:3
module.js:327
throw err;
^
Error: Cannot find module 'C:\Program Files\nodejs\node_modules\npm\bin\node_modules\npm\bin\npm-cli.js'
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at Function.Module.runMain (module.js:441:10)
at startup (node.js:139:18)
at node.js:968:3
Can someone help me how to resolve this issue, as i tried multiple times and restarted my pc.cordova issue
Please check the attached image for the reference and let me know what changes / how to resolve this issue

Resources