Yo angular generator throwing error - node.js

Having trouble getting yo angular generator to run, have had no problem on other computers, this is a fresh install on this one. Here is the error
/usr/local/lib/node_modules/yo/node_modules/configstore/node_modules/mkdirp/index.js:89
throw err0;
^
Error: EACCES, permission denied '/Users/Alex/.config/configstore'
at Error (native)
at Object.fs.mkdirSync (fs.js:751:18)
at Function.sync (/usr/local/lib/node_modules/yo/node_modules/configstore/node_modules/mkdirp/index.js:70:13)
at Object.create.all.get (/usr/local/lib/node_modules/yo/node_modules/configstore/index.js:41:13)
at Object.Configstore (/usr/local/lib/node_modules/yo/node_modules/configstore/index.js:27:44)
at new Insight (/usr/local/lib/node_modules/yo/node_modules/insight/lib/index.js:36:34)
at Object.<anonymous> (/usr/local/lib/node_modules/yo/lib/cli.js:122:15)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
The odd thing about this is when I go to my users/alex/.config there is no configstore folder.

Probably it´s because you have the .config folder and subsequent ones with root ownership. Try changing the ownership of that folder to your user recursively (to include subfolders). In order to do that:
sudo chown -R $(whoami):staff /Users/Alex/.config/
After that, yeoman should run and you'll be able to see the folder.
Hope that helps.

Related

Node JS: Electron problem with "electron.asar" file

I have a NodeJS application that is packed with Electron to create a Windows x64 executable.
The packaged app works fine on the majority of the PC, but I don't know for what reason, in some PC the app fail randomly.
The error stack is:
"Error: ENOENT: no such file or directory, open 'C:\app\app-desktop-win32-x64\resources\electron.asar\browser\api\dialog.js'
at Object.openSync (fs.js:453:3)
at Object.func [as openSync] (electron/js2c/asar.js:138:31)
at Object.readFileSync (fs.js:353:35)
at Object.fs.readFileSync (electron/js2c/asar.js:580:40)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:850:22)
at Module.load (internal/modules/cjs/loader.js:701:32)
at tryModuleLoad (internal/modules/cjs/loader.js:633:12)
at Function.Module._load (internal/modules/cjs/loader.js:625:3)
at Module.require (internal/modules/cjs/loader.js:739:19)
at require (internal/modules/cjs/helpers.js:14:16)"
Someone has fight against this error? Any idea or suggestion?
In some PC, the error disappear renaming the folder that contains the app, but in one PC, the error persist indefinitely.
Finally, I found how to do this.
I extract the asar files manually before pack and distribute my app and the problem gone.
Is a bit tedious, but is the unique solution that was valid for all the PC's.

EACCES: permission denied with Node JS

I get below error when write a file (file name is book) with Node.js, could you please help?
Error: EACCES: permission denied, open '/book'
at Object.openSync (fs.js:443:3)
at Object.writeFileSync (fs.js:1163:35)
at Object.<anonymous> (/home/ubuntu/remoteserver/ionicappGate.js:375:6)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
at startup (internal/bootstrap/node.js:266:19)
The code is as below
const fs = require('fs');
const path = "/book";
//do whatever required after initialize
fs.writeFileSync(path, "hello book");
app.use("/", router);
app.listen(4000, () => console.log('Platform Server running on port 4000'))
You're trying to write to the root of your file system "/book". This is probably write protected (default in Linux). If you really mean to write to that directory, check to make sure the user running the node process has write permissions to that folder. Otherwise, change to the path relative to the script such as ./book and again make sure the user running the node process has write permissions to that folder.
I hope the script command below may resolve your problem:
chmod -R 755 book/*
Try to check permissions to file with fs.access(path[, mode], callback).
Also check your folder permissions. Read more detail about file system permissions here

node-sass error deploying react to elastic beanstalk

I am trying to deploy a reactjs app to an elastic beanstalk instance and seem to be encountering several issues.
1) I am receiving this error in the health section for elastic beanstalk:
/opt/elasticbeanstalk/containerfiles/ebnode.py --action npm-install
node-sass#4.9.3 install /tmp/deployment/application/node_modules/node-sass
node scripts/install.js
Unable to save binary
/tmp/deployment/application/node_modules/node-sass/vendor/linux-x64-57
: { Error: EACCES: permission denied, mkdir
'/tmp/deployment/application/node_modules/node-sass/vendor' at
Object.fs.mkdirSync (fs.js:885:18) at sync
(/tmp/deployment/application/node_modules/mkdirp/index.js:71:13) at
Function.sync
(/tmp/deployment/application/node_modules/mkdirp/index.js:77:24) at
checkAndDownloadBinary
(/tmp/deployment/application/node_modules/node-sass/scripts/install.js:114:11)
at Object.
(/tmp/deployment/application/node_modules/node-sass/scripts/install.js:157:1)
at Module._compile (module.js:652:30) at Object.Module._extensions..js
(module.js:663:10) at Module.load (module.js:565:32) at tryModuleLoad
(module.js:505:12) at Function.Module._load (module.js:497:3) errno:
-13, code: 'EACCES', syscall: 'mkdir', path: '/tmp/deployment/application/node_modules/node-sass/vendor' }
2) At the same time it appears as if node and npm are claiming all of the resources for my ec2 instance and this seems to continue even after the deployment fails.
What could be the cause of this failure? The other packages seems to be deploying as they are in the node_modules folder? Additionally, why would node take up resources in this fashion?
The reactjs app is using webpack and node-sass ^4.9.3 and node version 8.11.3 which works on my local environment.
Update: .npmrc solved the permission issue. I am still having a problem with the cpu being 100%. In the build script, the code is not getting past this line, I adding console.log lines at various points in the code:
let compiler = webpack(config);
After this line is hit, I am not seeing any advancement. Could this be a webpack issue?
I think this might the same issue described here
So apparently npm install takes too long during automated deployments
on t1.micro instances, bumping to a t2.small gives enough power to get
the task done.
There is an alternative js only module just called sass. Seems to work ok, but not as up to date as none-sass.

How do I include a root CA certifciate in my node JS server?

I'm using npm v 5.7.1 on Mac High Sierra. I just installed this module
npm install ssl-root-cas
(for some reason, adding "-g" didn't work). Then i have this in my JS file
require('ssl-root-cas')
.inject()
.addFile(fs.readFileSync(conf.root_cert));
However, upon executing the above code (specifically the "inject()" line), I get the error
/Users/satishp/Documents/workspace/projA/node_modules/ssl-root-cas/ssl-root-cas.js:3637
var filepaths = filepath.split(/\//g);
^
TypeError: filepath.split is not a function
at Array.module.exports.rootCas.addFile (/Users/satishp/Documents/workspace/projA/node_modules/ssl-root-cas/ssl-root-cas.js:3637:28)
at Object.<anonymous> (/Users/satishp/Documents/workspace/projA/server.js:79:3)
at Module._compile (module.js:662:30)
at Object.Module._extensions..js (module.js:673:10)
at Module.load (module.js:575:32)
at tryModuleLoad (module.js:515:12)
at Function.Module._load (module.js:507:3)
at Function.Module.runMain (module.js:703:10)
at startup (bootstrap_node.js:193:16)
at bootstrap_node.js:660:3
I'm somewhat confused about how to proceed. How do I overcome this error?
You just need to pass the file path for the addFile function, no need to manually load the file content:
require('ssl-root-cas')
.inject()
.addFile(conf.root_cert);

How generate r.js using node dist.js

In the requireJS site they said that We can generate the r.js using
"node dist.js"
Source http://requirejs.org/docs/node.html
for me it does make error :
node git:(develop) ✗ node dist.js
fs.js:549 return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
^
Error: ENOENT: no such file or directory, open 'build/jslib/x.js'
at Error (native)
at Object.fs.openSync (fs.js:549:18)
at Object.fs.readFileSync (fs.js:397:15)
at Object.<anonymous> (/Users/mtaboubi/www/capsana-portal/webapp/unified-portal/src/main/webapp/node/dist.js:21:19)
at Module._compile (module.js:434:26)
at Object.Module._extensions..js (module.js:452:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:475:10)
at startup (node.js:117:18)
Any help ? thank you
Sounds like there might an error in your version of dist.js / fs.js.
Could you try running node dist.js on the original version of the r.js repository here?
If that works, then you'll have to do further troubleshooting on your r.js file to get to the bottom of the issue.
Otherwise, it's an issue with your development environment, in which case you can post the errors here.

Resources