I am having a requirement where node_modules required for a project are already installed and stored somewhere.
And we are running multiple instances of the angular project each inside a separate docker container and we mount the node_modules folder to these containers.
So basically same node_modules folder is shared among all these running containers.
Everything works fine, but when we run testcases -> npm run test (jest --json --outputFile=./testOutput.json; node transformJestOutputToMochaStyle.js)
its failing with the below error, which is obvious as we are mounting the node_modules folder as read only.
My Question is is there any way we can specify any custom directory which can be used by ngcc for creating the related temp files like - .ngcc_lock_file etc. ?
gxjc5w#84d7538af516:~/project/application$ npm run test
> angular-interview#0.0.0 test
> jest --json --outputFile=./testOutput.json; node transformJestOutputToMochaStyle.js
Determining test suites to run...
ngcc-jest-processor: running ngcc
Error: EROFS: read-only file system, open '/deps/node_modules/.ngcc_lock_file'
at Object.openSync (node:fs:585:3)
at Module.writeFileSync (node:fs:2157:35)
at NodeJSFileSystem.writeFile (file:///deps/node_modules/#angular/compiler-cli/bundles/chunk-TOKOIIBI.js:357:9)
at LockFileWithChildProcess.write (file:///deps/node_modules/#angular/compiler-cli/bundles/chunk-2LU77VSE.js:1730:13)
at AsyncLocker.create (file:///deps/node_modules/#angular/compiler-cli/bundles/chunk-2LU77VSE.js:1682:30)
at AsyncLocker.lock (file:///deps/node_modules/#angular/compiler-cli/bundles/chunk-2LU77VSE.js:1671:16)
at ClusterExecutor.execute (file:///deps/node_modules/#angular/compiler-cli/bundles/chunk-2LU77VSE.js:1566:26)
at mainNgcc (file:///deps/node_modules/#angular/compiler-cli/bundles/chunk-2LU77VSE.js:2113:19)
at file:///deps/node_modules/#angular/compiler-cli/bundles/ngcc/main-ngcc.js:32:11
at file:///deps/node_modules/#angular/compiler-cli/bundles/ngcc/main-ngcc.js:42:3
Error: Jest: Got error running globalSetup - /deps/node_modules/jest-preset-angular/global-setup.js, reason: NGCC failed .
at runNgccJestProcessor (/deps/node_modules/jest-preset-angular/build/utils/ngcc-jest-processor.js:42:19)
at /deps/node_modules/jest-preset-angular/build/config/global-setup.js:10:56
at Generator.next (<anonymous>)
at /deps/node_modules/tslib/tslib.js:118:75
at new Promise (<anonymous>)
at Object.__awaiter (/deps/node_modules/tslib/tslib.js:114:16)
at globalSetup (/deps/node_modules/jest-preset-angular/build/config/global-setup.js:6:35)
at /deps/node_modules/#jest/core/build/runGlobalHook.js:125:19
at ScriptTransformer.requireAndTranspileModule (/deps/node_modules/#jest/transform/build/ScriptTransformer.js:905:24)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
node:internal/fs/utils:344
throw err;
^
Error: ENOENT: no such file or directory, open './testOutput.json'
at Object.openSync (node:fs:585:3)
at Object.readFileSync (node:fs:453:35)
at readTestOutput (/candidate_files/preview/gxjc5w/editablequestions-angular7-q1675409290800/application/transformJestOutputToMochaStyle.js:41:28)
at Object.<anonymous> (/candidate_files/preview/gxjc5w/editablequestions-angular7-q1675409290800/application/transformJestOutputToMochaStyle.js:50:20)
at Module._compile (node:internal/modules/cjs/loader:1103:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
at node:internal/main/run_main_module:17:47 {
errno: -2,
syscall: 'open',
code: 'ENOENT',
path: './testOutput.json'
}
I tried looking for it, could not find anything.
ngcc needs to write the updated packages into the node_modules tree, so just storing the lockfile elsewhere won't help. The CLI won't run ngcc when a readonly filesystem is detected.
Since v12.0.0, jest-preset-angular provide a possibility to skip ngcc via globalThis by doing the following -
globalThis.ngJest = {
skipNgcc: true,
tsconfig: 'tsconfig.spec.json', // this is the project root tsconfig
};
module.exports = {
//...
globalSetup: 'jest-preset-angular/global-setup',
};
For details check this - https://thymikee.github.io/jest-preset-angular/docs/guides/angular-ivy/#control-ngcc-processing
Related
I have created a simple React application that works locally, but for some reason, Heroku keeps giving me this error message when I try to deploy it. I have been googling for solutions and trying everything I can find, but this error still persists. I am still a beginner in this, and would gladly appreciate any help or advice. If anyone would like to try it, my repository which I am trying to deploy from is https://github.com/shittake/findabudbud. Thank you in advance.
-----> Build
Running build
> findabudbud#1.0.0 build
> react-scripts build
node:internal/modules/cjs/loader:361
throw err;
^
Error: Cannot find module '/tmp/build_2e0389cc/node_modules/fs-extra/lib/index.js'. Please verify that the package.json has a valid "main" entry
at tryPackage (node:internal/modules/cjs/loader:353:19)
at Function.Module._findPath (node:internal/modules/cjs/loader:566:18)
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:27)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object. (/tmp/build_2e0389cc/node_modules/react-scripts/scripts/build.js:36:12)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32) {
code: 'MODULE_NOT_FOUND',
path: '/tmp/build_2e0389cc/node_modules/fs-extra/package.json',
requestPath: 'fs-extra'
}
-----> Build failed
We're sorry this build is failing! You can troubleshoot common issues here:
https://devcenter.heroku.com/articles/troubleshooting-node-deploys
Some possible problems:
- node_modules checked into source control
https://devcenter.heroku.com/articles/node-best-practices#only-git-the-important-bits
- Node version not specified in package.json
https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version
Love,
Heroku
! Push rejected, failed to compile Node.js app.
! Push failed
I am new to webpack and was going through webpack getting-started guide but when I try to run npx webpack it throws error:
'js\webpack-demo\node_modules\.bin\' is not recognized as an internal or external command,
operable program or batch file.
internal/modules/cjs/loader.js:888
throw err;
^
Error: Cannot find module 'C:\Users\Abc\Dev\webpack\bin\webpack.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:885:15)
at Function.Module._load (internal/modules/cjs/loader.js:730:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
Lokking at the error, I can see that it is looking for webpack in "Dev" but I am currently in "Dev/Web/webpack-demo" and I have installed webpack locally here.
I have installed both webpack and webpack-cli.
Been trying to install nodemon globally and although installed, I got a permission error when trying to run nodemon app.js in my terminal (using zsh). The following error:
/usr/local/lib/node_modules/nodemon/node_modules/configstore/index.js:53
throw err;
^
Error: EACCES: permission denied, open '/Users/carlosgrijalva/.config/configstore/update-notifier-nodemon.json'
You don't have access to this file.
at Error (native)
at Object.fs.openSync (fs.js:641:18)
at Object.fs.readFileSync (fs.js:509:33)
at Object.get (/usr/local/lib/node_modules/nodemon/node_modules/configstore/index.js:34:26)
at Object.Configstore (/usr/local/lib/node_modules/nodemon/node_modules/configstore/index.js:27:44)
at new UpdateNotifier (/usr/local/lib/node_modules/nodemon/node_modules/update-notifier/index.js:34:17)
at module.exports (/usr/local/lib/node_modules/nodemon/node_modules/update-notifier/index.js:123:23)
at Object.<anonymous> (/usr/local/lib/node_modules/nodemon/bin/nodemon.js:15:27)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
I found this article: https://docs.npmjs.com/getting-started/fixing-npm-permissions
And followed the instructions in option 1 by running the following command:
sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}
I'm debating reinstalling node and since i'm using 6.11 and figured I might as well use the latest version but I'm unsure if that's the wisest move at this point. If anyone has any other suggestions I'd really appreciate it.
I'm learning nodejs through some tutorials and so far it went smooth. Now I got an error and I'm stuck. Can anyone help me with it.
This is my app.js file
var greet5 = require('/greet5');
greet5.greet();
And this is my greet5.js file which is located in same directory as app.js
var greeting = "Hello from Revieling Module pattern";
function greet(){
console.log(greeting);
}
module.exports = {
greet : greet
}
when I run node app.js on terminal this is the error I'm facing.
module.js:328
throw err;
^
Error: Cannot find module '/greet5'
at Function.Module._resolveFilename (module.js:326:15)
at Function.Module._load (module.js:277:25)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/home/pankaja/Nodejs/Tests/23-Module Patterns/app.js:19:14)
at Module._compile (module.js:410:26)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Function.Module.runMain (module.js:442:10)
Can anyone help me with this. Thanks
The README.md file of the nodejs project, appeared after running nodejs install, explains you how to run the web app through nodejs.
It says you have to execute npm run dev on the command line.
Here you are the default README.md:
# Front End Boilerplate
Front-end boilerplate for creating new web projects with Gulp.js and everything you need to get started.
# Getting Started
Required! Gulp installed `npm install -g gulp`
```
$ cd html-boilerplate
$ npm install
$ npm run dev
```
# Build to production
```
$ npm run build
```
Thank you for your suggestions!
I am trying to run samples regarding webrtc. For that I went to
https://bitbucket.org/webrtc/codelab/src/50a47bb092483fd7ca27998a365dff434919bf89?at=master
At step 5 I needed to run server.js. For that I opened my Windows Command prompt and entered:
C:\Program Files\nodejs>node D:\GITProjects\codelab\complete\step5\server.js
But I got this error:
module.js:338
throw err;
^ Error: Cannot find module 'node-static'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (D:\GITProjects\codelab\complete\step5\server.js:1:76)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:501:10)
I have already installed node-static module and it is present at
"C:\Program Files\nodejs\node_modules\node-static"
Still I am getting the error "Cannot find module 'node-static'".
Environmental "PATH" variable is set to "C:\Users\user\AppData\Roaming\npm"
I can see the node-static folder is present at "C:\Users\user\AppData\Roaming\npm\node_modules\node-static" path too.
Edit:
Based on the comments I tried this on Windows Command Prompt to install node-static:
C:\Program Files\nodejs>npm install node-static -g
I got this as the output:
C:\Users\user\AppData\Roaming\npm\static -> C:\Users\user\AppData\Roaming\np
m\node_modules\node-static\bin\cli.js
node-static#0.7.6 C:\Users\user\AppData\Roaming\npm\node_modules\node-static
├── mime#1.3.4
├── colors#1.1.2
└── optimist#0.6.1 (wordwrap#0.0.3, minimist#0.0.10)
Can you help me location the cause of my issue?
node_static is not an inbuilt nodejs module so there should be a folder node_modules in your doc root folder(step5) with this module in it or create a package.json and list it as a dependency then run npm install before node server.js
just run npm install on cd into the "complete" directory i.e codelab\complete