Error when deploying to modulus - node.js

I'm trying to deploy my first meteor app to modulus.io but I'm getting the following error in the log:
Error: EACCES, permission denied '/mnt/data/cfs'
at Object.fs.mkdirSync (fs.js:654:18)
at sync (/mnt/data/1/node_modules/mkdirp/index.js:55:12)
at sync (/mnt/data/1/node_modules/mkdirp/index.js:61:24)
at Function.sync (/mnt/data/1/node_modules/mkdirp/index.js:61:24)
at new FS.Store.FileSystem (packages/cfs:filesystem/filesystem.server.js:37:1)
at app/leads.js:69:3
at app/leads.js:332:3
at /mnt/data/1/programs/server/boot.js:222:10
at Array.forEach (native)
at Function._.each._.forEach (/mnt/data/1/node_modules/underscore/underscore.js:79:11)
It's obviously something about permissions but don't know how to fix it. Any ideas?

It seems you are trying to create a directory in /mnt/data/cfs, and you don't have permissions from the OS to do that. From quickly looking over the modulus.io documentation (http://help.modulus.io/customer/portal/articles/1653448-file-storage), the platform allows you to write in exactly two directories: your local app directory, and /mnt/data/tmp. You are trying to write to a different directory. So that won't work.
Try using /mnt/data/tmp/cfs instead of /mnt/data/cfs.
It looks like you are using CollectionFS, and that package is using the directory in question. If that is the case, then you'll need to update the path option for that package:
var myStore = new FS.Store.FileSystem("something", {
path: "/mnt/data/tmp/cfs",
});
BTW, I had to infer a lot from your error (use of CFS, what directory you are trying to create). When asking questions, it is better
to provide that sort of detail.

Related

"Error: EACCES: permission denied" - running Meteor app (OHIF) on AWS EC2 Instance

I am running a Meteor application (a modified version of OHIF) on an AWS EC2 Instance (t2.medium running Amazon Linux 2).
When attempting to launch the application using meteor, or run any commands in meteor at all, I am seeing the below error. I have tried many different approaches based on other similar issues, primarily using chown to reassign ownership of all the indicated folders to ec2-user, but no matter what I try I keep getting this EACCES: permission denied error.
[ec2-user#ip-10-1-2-35 APPFolder]$ meteor npm install
/home/ec2-user/.meteor/packages/meteor-tool/.1.12.0.13oys96.0sq8++os.linux.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.linux.x86_64/tools/cli/dev-bundle.js:120
throw e;
^
Error: EACCES: permission denied, stat
'/Cansrdata/cansrohif/OHIFViewer/.meteor/local/dev_bundle'
at Object.statSync (fs.js:1016:3)
at statOrNull (/home/ec2-user/.meteor/packages/meteor-tool/.1.12.0.13oys96.0sq8++os.linux.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.linux.x86_64/tools/cli/dev-bundle.js:117:21)
at getDevBundleDir (/home/ec2-user/.meteor/packages/meteor-tool/.1.12.0.13oys96.0sq8++os.linux.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.linux.x86_64/tools/cli/dev-bundle.js:37:25)
at Object.<anonymous> (/home/ec2-user/.meteor/packages/meteor-tool/.1.12.0.13oys96.0sq8++os.linux.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.linux.x86_64/tools/cli/dev-bundle.js:177:20)
at Object.<anonymous> (/home/ec2-user/.meteor/packages/meteor-tool/.1.12.0.13oys96.0sq8++os.linux.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.linux.x86_64/tools/cli/dev-bundle.js:180:3)
at Module._compile (internal/modules/cjs/loader.js:1137:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
at Module.load (internal/modules/cjs/loader.js:985:32)
at Function.Module._load (internal/modules/cjs/loader.js:878:14)
at Module.require (internal/modules/cjs/loader.js:1025:19) { errno: -13, syscall: 'stat', code: 'EACCES', path:
'/app/.meteor/local/dev_bundle' }
This happens no matter what I attempt. I have used the chown and chmod functions to reassign permissions for all directories and all files mentioned in the error log, as well as all directories and files which may be pointed to from those directories using relative links.
In the system (using ls -l) these all show as assigned to the default ec2-user user (which I believe from lots of googling / GitHub / Stack Overflow is the correct status, but I don't know for sure). I have also reinstalled meteor to see if this will change the permissions, without success.
The application was previously running on this EC2 Instance, so I am unsure why this doesn't work when I try it now.
Do you know why this is happening, and what I can do to fix it?
I was able to help Craig with that specific problem and it was done as follows:
The problem is meteor runs with root user (not recommended)
To get rid of this problem, stop the app servers, which in this case was tomcat with the command:
sudo systemctl stop tomcat.service
Optional Step: Just do it if you want for security reasons
cp -a local/home/ec2-user/meteor_local_copy
Go to your project folder:
cd myProject/.meteor/local
Warn: Delete only the /local directory (not /.meteor/local):
There is no problem deleting, it will be re-created:
sudo rm -rf ../myProject/.meteor/local
Now update your meteor:
meteor update
Wait until a message like this appears:
"Installed. Run 'meteor update --release 2.0' inside of a particular..."
In your project directory run:
meteor npm rebuild
Start the aplication server again:
systemctl start tomcat.service
Check if the problem was resolved!

Puppet error when using classes

I am starting using puppet to manage many servers, the problem is that whenever I try to use a class, new relic for example:
node 'mynode' {
class {'newrelic::server::linux':
newrelic_license_key => '***',
}
}
It fails, and returns the following error:
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Puppet::Parser::AST::Resource failed with error ArgumentError: Could not find declared class newrelic::server::linux at /etc/puppet/manifests/site.pp:3 on node mynode
I have installed fsalum-newrelic on the master, and everything works fine when using files, packages, services etc. What am I doing wrong?
The catalog compiler will look for class newrelic::server::linux at newrelic/manifests/server/linux.pp relative to each directory in your module path. (Note: newrelic, NOT fsalum-newrelic.) Make certain that you indeed did install the module such that such a file exists in your modulepath, and make sure that it is readable by the puppetmaster process.
Note, too, that "readable by the puppetmaster process" means more than just the ownership and permissions of the file itself. It also involves ownership and permissions of all the directories in the path to that file, and possibly other forms of access control, such as ACLs and SELinux conext and policy.
Find out where you are actually installing the new puppet forge modules using perhaps a unix utility like "locate".
Then look in the the /etc/puppet/puppet.conf at the "basemodulepath" and check that the place it is installed is in the path
Here is my basemodulepath
basemodulepath = $confdir/environments/production/modules:$confdir/environments/production/local_modules:/etc/puppet/modules
The external modules I am using are either in /etc/puppet/modules or in /etc/puppet/enviroments/production/modules

ENOENT, no such file or directory on fs.mkdirSync

I'm currently starting up my NodeJS application and I have the following if-statement:
Error: ENOENT, no such file or directory './realworks/objects/'
at Object.fs.mkdirSync (fs.js:654:18)
at Object.module.exports.StartScript (/home/nodeusr/huizenier.nl/realworks.js:294:7)
The weird thing, however, is that the folder exists already, but the check fails on the following snippet:
if(fs.existsSync(objectPath)) {
var existingObjects = fs.readdirSync(objectPath);
existingObjects.forEach(function (objectFile) {
var object = JSON.parse(fs.readFileSync(objectPath+objectFile));
actualObjects[object.ObjectCode] = object;
});
}else{
fs.mkdirSync(objectPath); // << this is line 294
}
I fail to understand how a no such file or directory can occur on CREATING a directory.
When any folder along the given path is missing, mkdir will throw an ENOENT.
There are 2 possible solutions (without using 3rd party packages):
Recursively call fs.mkdir for every non-existent directory along the path.
Use the recursive option, introduced in v10.12:
fs.mkdir('./path/to/dir', {recursive: true}, err => {})
Solve here How to create full path with node's fs.mkdirSync?
NodeJS version 10.12.0 has added a native support for both mkdir and mkdirSync to create a directory recursively with recursive: true option as the following:
fs.mkdirSync(targetDir, { recursive: true });
And if you prefer fs Promises API, you can write
fs.promises.mkdir(targetDir, { recursive: true });
When you are using fs.mkdir or fs.mkdirSync, while passing the path like folder1/folder2/folder3, folder1 and folder2 must exist otherwise you will get the above error.
The following worked for me:
fs.mkdir( __dirname + '/realworks/', err => {})
Problem was caused by forever running the application relative to the working directory the forever start command is called in, not the location of the application entrypoint.
Try:
fs.mkdir('./realworks/', err => {})
The reason for the error is that if any of the folders exist along the path given to fs.mkdir or fs.mkdirSync these methods will throw/callback with an ENOENT error.
ENOENT is described in the linux documentation as the following:
No such file or directory (POSIX.1-2001).
Typically, this error results when a specified path‐
name does not exist, or one of the components in the
directory prefix of a pathname does not exist, or the
specified pathname is a dangling symbolic link.
Another possible reason for ENOENT is that you lack sufficient privileges to create the directory.
This happened to me while building a docker image where I didn't have sufficient privilege to create a subfolder in the current WORKDIR. Changing the owner of the folder using --chown=user:usergroup OR changing the USER to the root user for the directive were both valid solutions to the problem.
WHAT WORKED FOR ME WAS ;
Deleting my yarn.lock, package-lock.json, and nodemodules
reinstalling with yarn build
restarting my local server
so... you probably might be using ubuntu terminal to create your react app.
It happens to me that I am testing the ubuntu terminal that windows recently launched to be installed on windows computer, like a virtual machine but actually not so messy.
I occured to have the same error as you folk, after testing all the options that the community has given before, none of them work. However, i did find a solution for my problem. It was giving me the ENOENT error, like, test file or directory not found. but I was there indeed. I was using npm start, and came up with the idea of using sudo npm start... and it worked.

Error: EPERM, operation not permitted with Node.js and Etherpad Lite

I'm attempting to get an Etherpad Lite site up and running with IIS on my computer before I upload it to Azure for Web Sites, but I get this error when I try (http://pastebin.com/4rZWbqix):
iisnode encountered an error when processing the request. HRESULT: 0x2
HTTP status: 500 HTTP reason: Internal Server Error
You are receiving this HTTP 200 response because
system.webServer/iisnode/#devErrorsEnabled configuration setting is
'true'.
In addition to the log of stdout and stderr of the node.exe process,
consider using debugging and ETW traces to further diagnose the
problem.
The last 64k of the output generated by the node.exe process to stdout
and stderr is shown below: fs.js:520 return
binding.lstat(pathModule._makeLong(path));
^ Error: EPERM, operation not permitted 'C:\Users\Matthew'
at Object.fs.lstatSync (fs.js:520:18)
at Object.realpathSync (fs.js:1047:21)
at tryFile (module.js:142:15)
at Function.Module._findPath (module.js:181:18)
at Function.Module._resolveFilename (module.js:336:25)
at Function.Module._load (module.js:280:25)
at Module.runMain (module.js:492:10)
at process.startup.processNextTick.process._tickCallback (node.js:244:9)
There is no fs.js file in Etherpad's directory, so I would assume that it's some part of Node.js that's having a problem. I'm new to Node.js, so any help would be appreciated.
EDIT 1: I'm currently looking into alternatives to Azure, and granting permissions to C:\Users\Matthew. But would it be possible to somehow modify fs.js to put a try/catch around binding.lstat?
EDIT 2: After playing around with it a little (adding the permissions worked!), I've gotten it to work. But now loading 127.0.0.1:81 returns:
iisnode encountered an error when processing the request. HRESULT: 0x2
HTTP status: 500 HTTP reason: Internal Server Error
You are receiving this HTTP 200 response because
system.webServer/iisnode/#devErrorsEnabled configuration setting is
'true'.
In addition to the log of stdout and stderr of the node.exe process,
consider using debugging and ETW traces to further diagnose the
problem.
The last 64k of the output generated by the node.exe process to stdout
and stderr is shown below:
[x1B][33m[2012-10-03 20:28:13.587] [WARN]
console - [x1B][39mNo settings file found. Continuing using defaults!
[x1B][32m[2012-10-03 20:28:14.338] [INFO] console - [x1B][39mInstalled
plugins:
It would seem like this isn't an error, since what's outputted is what's expected, but it seems to stop at plugins.formatPlugins().
Make sure the user identity associated with the IIS application pool running your node.js application has appropriate filesystem permissions to the location where you deployed your application (looks like c:\users\matthew in this case).
If you are running your app within the Default App Pool and using default IIS user, you should be able to grant necessary permissions with:
%systemdrive%\windows\system32\icacls.exe c:\users\matthew /grant IIS_IUSRS:(OI)(CI)F
Case
Error: EPERM, operation not permitted 'C:\Users\Matthew'
This error occour because the user IIS_IUSRS, does not have access to this folder C:\Users\Matthew
Resolution
You can put your application on a 'public folder', example: 'C:\Test\[yourapplication]' and gives access to user IIS_IUSRS only to this folder.
It is about permission on the folder 'C:\Users\Matthew'. Take ownership and give modify permissions.
I had the same issue, and when I tried to use the latest node version via
nvm use [some node version 10.12.0 in my case] it output that it succeed but when I run node -v it showed to me that actually I'm on a node of 8.
I solved that by login as second windows user (although they both admins and node installed on C:/) and there I use the nvm use 10.12.0 to replace the node version, and when I back login with current user it worked.
I wouldn't recommend Azure for hosting Etherpad Lite, we don't optimize for Microsoft's services, this includes Microsoft Windows. If it's an option please use linux to host your node instances, you will be much happier in my experience.

Problem with node.js and Redis-server?

I intended to implement a chat feature in my rails application. After a brief backup work I found JUGGERNAUT is the best option. By going to through http://juggernaut.rubyforge.org/
I have successfully implemented the juggernaut in my application.
Presently I'm all set to implement chat feature and after a vigorous surfing over web I couldn't get good tutorial to implement it but I found the some part of implementation at http://www.golygon.com/2010/12/private-chat-room-in-ruby-on-rails-3-0/. I decided to follow it but initially to implement the tutorial we need to have redis server and node.js in our system. I installed both in my environment.
But I'm facing the following problem as follows:
If I try
redis-server, I'm getting the following error
[11440] 08 Aug 10:08:16 # Warning: no config file specified, using the default config. In order to specify a config file use 'redis-server /path/to/redis.conf'
[11440] 08 Aug 10:08:16 # Opening port: bind: Address already in use
and as per the tutorial
if I try
sudo node server.js, I'm getting the following error
[sudo] password for re5:
node.js:63
throw e;
^
Error: ENOENT, No such file or directory '/home/re5/Documents/task17/server.js'
at Object.openSync (fs:153:18)
at Object.readFileSync (fs:94:15)
at Module._loadScriptSync (node.js:468:39)
at Module.loadSync (node.js:338:12)
at Object.runMain (node.js:522:24)
at Array.<anonymous> (node.js:756:12)
at EventEmitter._tickCallback (node.js:55:22)
at node.js:773:9
As I don't know much about the redis and node I'm unable to figure out what was the problem regarding to this errors.
I'm stuck and couldn't go further as I'm not sure whether this two are configured perfectly or not.
currently I'm using rails 3.0.7 and ruby 1.8.7
Can any one help me out.
Well your first error is quite simple to understand.
[11440] 08 Aug 10:08:16 # Opening port: bind: Address already in use
This means that there is aready a server bound to that port and using it as a server, this can happen if you have other applications/servers running or if you try to have mutiple instances of the server run at one time. To fix this you need to stop the process and then start it back up again. You can usually do this by closing all of your terminal windows or using your operating systems process manager to terminate the process, if those methods dont work for you try shutting your computer down and starting it back up. If you are still unable to start the Redis server after this then there are some more steps we can take.
The next error is due to node.js not being able to find a file that it needs. Reinstalling node.js should fix this problem for you.
Let me know if this fixes your problem or if you need more help.

Resources