TimsMac:tmp tjhart$ ember addon bar
version: 0.1.2
EACCES, permission denied '/usr/local/lib/node_modules/ember-cli/blueprints/addon/files/package.json'
Error: EACCES
permission denied '/usr/local/lib/node_modules/ember-cli/blueprints/addon/files/package.json'
at Object.fs.openSync (fs.js:438:18)
at Object.fs.writeFileSync (fs.js:977:15)
at Class.module.exports.generatePackageJson (/usr/local/lib/node_modules/ember-cli/blueprints/addon/index.js:27:8)
at Class.module.exports.files (/usr/local/lib/node_modules/ember-cli/blueprints/addon/index.js:78:10)
at Class.Blueprint.install (/usr/local/lib/node_modules/ember-cli/lib/models/blueprint.js:327:36)
at Class.module.exports.Task.extend.run (/usr/local/lib/node_modules/ember-cli/lib/tasks/install-blueprint.js:50:24)
at Class.module.exports.Command.extend.run (/usr/local/lib/node_modules/ember-cli/lib/commands/init.js:72:29)
at $$$internal$$tryCatch (/usr/local/lib/node_modules/ember-cli/node_modules/rsvp/dist/rsvp.js:470:16)
at $$$internal$$invokeCallback (/usr/local/lib/node_modules/ember-cli/node_modules/rsvp/dist/rsvp.js:482:17)
at $$$internal$$publish (/usr/local/lib/node_modules/ember-cli/node_modules/rsvp/dist/rsvp.js:453:11)
TimsMac:tmp tjhart$
Creating ember projects, building, testing, serving all work fine. This seems odd since I see reports that others can use the addon generator without issue.
This is just a permission issue of that file(s) specifically. First you can try to just uninstall ember-cli globally and reinstall it. If that doesn't work, you could just dig into that folder directly and update the permissions.
Something like this should work
sudo chown -R tjhart /usr/local/lib/node_modules/ember-cli/blueprints/addon
I have the same error. This is not a permission problem, the file just isn't there.
@cerdiogenes The error specifically says "permission denied", if you can provide steps so that we are able to reproduce this error. Please do and we can reopen this
Thanks @jakecraige. Probably I did something wrong when I set the permissions for the first time and the error persisted.
Now, after setting permissions, everything worked fine.
But the error is misleading. This is my output for "sudo ls -a /usr/lib/node_modules/ember-cli/blueprints/addon/files/":
. .. addon addon-config app Brocfile.js index.js README.md
As you "can" see, no package.json file.
@cerdiogenes I'm glad you got it figured out. To address your package.json thing, there isn't supposed to be one. See the tree here. It's actually generated in the blueprint's index.js file
Oh, I see now! Thanks for the kindness @jakecraige
I ran into the same problem, however i cannot see anything wrong with my permissions...
@jakecraige: in index.js you mentioned you can see in the first two lines of code, that the packagePath is determined, which should be /usr/local/lib/node_modules/ember-cli/blueprints/addon/files/package.json, and then this file is read by fs.readFileSync. Which should obviously fail if that file does not exist, which it doesn't. Or am I missing something?
I have the same issue with ember-cli 0.1.4, and I have tried to reinstall ember-cli
@simonihmig Where does it try to read that path? The file is actually automatically generated by the blueprint in the directory you are creating the addon. Rather than it being there already.
@bassmake Can you provide some more context to the error you're getting? Is it the same stack trace with permission errors? Also, npm / node versions are also helpful.
I am using Mint 17.1
node: v0.10.35
npm: 1.4.28
after ember addon sample-addon
version: 0.1.4
Looks like you have a different program called watchman, falling back to NodeWatcher
EACCES, permission denied '/usr/local/lib/node_modules/ember-cli/blueprints/addon/files/package.json'
Error: EACCES
permission denied '/usr/local/lib/node_modules/ember-cli/blueprints/addon/files/package.json'
at Object.fs.openSync (fs.js:439:18)
at Object.fs.writeFileSync (fs.js:978:15)
at Class.module.exports.generatePackageJson (/usr/local/lib/node_modules/ember-cli/blueprints/addon/index.js:29:8)
at Class.module.exports.files (/usr/local/lib/node_modules/ember-cli/blueprints/addon/index.js:81:10)
at Class.Blueprint.install (/usr/local/lib/node_modules/ember-cli/lib/models/blueprint.js:332:36)
at Class.module.exports.Task.extend.run (/usr/local/lib/node_modules/ember-cli/lib/tasks/install-blueprint.js:52:24)
at Class.module.exports.Command.extend.run (/usr/local/lib/node_modules/ember-cli/lib/commands/init.js:75:29)
at $$$internal$$tryCatch (/usr/local/lib/node_modules/ember-cli/node_modules/rsvp/dist/rsvp.js:470:16)
at $$$internal$$invokeCallback (/usr/local/lib/node_modules/ember-cli/node_modules/rsvp/dist/rsvp.js:482:17)
at $$$internal$$publish (/usr/local/lib/node_modules/ember-cli/node_modules/rsvp/dist/rsvp.js:453:11)
and empty folder sample-addon was created
@bassmake Looks like the permission error is when "writing" the package.json as seen by the stack showing fs.writeFileSync. Make sure you have permission to write to that directory.
Also, technically we're officially supporting npm 2.1.x now so upgrading npm would also be a good choice.
@jakecraige thank for answer,
the thing is if I run sudo ember addon sample-addon everything is OK, but I don't think that you have to have admin permissions to create new addon project.
and the npm 2.1.x point: I see on www.ember-cli.com that you support 1.4.6 now:
Currently, Ember CLI supports node 0.10.5 and npm 1.4.6.
and the npm 2.1.x point: I see on www.ember-cli.com that you support 1.4.6 now:
Currently, Ember CLI supports node 0.10.5 and npm 1.4.6.
this is incorrect, the readme states 2.x. I will fix the site.
I run sudo ember addon sample-addon
We do not support this. Be warned escalating privileges like this is a great way to screw yourselve. The permission system on you system exists for a reason.
Something like npm does not require escalated privileges, doing so in an ember-cli app gives approximately 32,000 random JS files the ability to accidentally or intentionally perform actions as root. Which means every file on your system, including local password hashes becomes readable + mutable.
just a simple typo of rmraf('/ path/to/file/iwant' (this was a mistake in npm some time ago), now has the ability to delete nearly everything on your system...
@stefanpenner I used sudo just to check if the problem with privileges will go away
@jakecraige
node: v0.10.35
npm: 2.1.14
I installed npm as root - is this a problem?
ember new some-ember-app works fine
ember addon some-addon still fails on
version: 0.1.4
Looks like you have a different program called watchman, falling back to NodeWatcher
EACCES, permission denied '/usr/local/lib/node_modules/ember-cli/blueprints/addon/files/package.json'
Error: EACCES
permission denied '/usr/local/lib/node_modules/ember-cli/blueprints/addon/files/package.json'
at Object.fs.openSync (fs.js:439:18)
at Object.fs.writeFileSync (fs.js:978:15)
at Class.module.exports.generatePackageJson (/usr/local/lib/node_modules/ember-cli/blueprints/addon/index.js:29:8)
at Class.module.exports.files (/usr/local/lib/node_modules/ember-cli/blueprints/addon/index.js:81:10)
at Class.Blueprint.install (/usr/local/lib/node_modules/ember-cli/lib/models/blueprint.js:332:36)
at Class.module.exports.Task.extend.run (/usr/local/lib/node_modules/ember-cli/lib/tasks/install-blueprint.js:52:24)
at Class.module.exports.Command.extend.run (/usr/local/lib/node_modules/ember-cli/lib/commands/init.js:75:29)
at $$$internal$$tryCatch (/usr/local/lib/node_modules/ember-cli/node_modules/rsvp/dist/rsvp.js:470:16)
at $$$internal$$invokeCallback (/usr/local/lib/node_modules/ember-cli/node_modules/rsvp/dist/rsvp.js:482:17)
at $$$internal$$publish (/usr/local/lib/node_modules/ember-cli/node_modules/rsvp/dist/rsvp.js:453:11)
@bassmake Yes that is likely the issue. See this article for how to install without it
I installed npm as root - is this a problem?
yes, this is related to my above comment. npm is userland, and shouldn't require escalated privs, even for installation.
thank you
Sorry, i don't intend to come off as hostile, I am just passionate about this topic. the sudo hammer is used often, with bad side affects. Even some of the npm team suggest using sudo to install, but the resulting implications are potentially serious.
I am unsure how to voice my concerns without being passionate, I will try to work on a better presentation of these concerns.
no problem, I haven't really though about npm this way.
As it is not clear from 'how to install npm' that I have used, something may be mentioned in the ember-cli guide to avoid problems like this (and to learn again that the easiest way is not always the best one).
Ya sometimes I think we need to allow people to install ember cli without npm. But that is another can of worms
As we revamp the website we need to keep this part of the getting started experience in mind
The addon blueprint writes temp package.json and bower.json files in the blueprint directory, so that it can inherit and modify the default app files. We are not doing this in afterInstall because if we modify the files after generation, the diff on ember init doesn't show changes (and users can't decline them).
We should probably change https://github.com/ember-cli/ember-cli/blob/master/blueprints/addon/index.js#L12-50 to write to the system temp dir and figure out how to make the blueprint use those files (to still allow the ember init diff to work).
@hjdivad we should take a look at this one this afternoon
Just ran into this problem when I thought I'd whip up a quick ember addon. 2 hours later I'm researching errors trying to reinstall npm not as root. I followed the linked guide's instructions for reinstalling node with brew but ran into more errors. I'll try the nvm way next but any chance there's an easier way?
@JKGisMe nvm is good, don't install npm as sudo
I got nvm and everything seemingly installed correctly and not as sudo. But now my project won't install dependencies correctly. Basically every single thing I've needed to do (relating to ember, node, bower, npm) since removing my old root npm & installing with nvm has errored except now I can successfully create an addon... I'm not sure the tradeoff was worth it.
Met the problem. When will it be fixed?
Current workaround:
sudo ember addon [addon-name]
sudo chown -R [user:group] [addon-name/]
4 months since I had this problem. The fix will happen whenever you fix your node/npm permissions.
Personally, I did this: http://stackoverflow.com/questions/11177954/how-do-i-completely-uninstall-node-js-and-reinstall-from-beginning-mac-os-x/11178106#11178106
Everything works great now and I forgot all about it ever since.
For what it's worth, I experienced this issue using a docker container based on the node image.
Most helpful comment
This is just a permission issue of that file(s) specifically. First you can try to just uninstall ember-cli globally and reinstall it. If that doesn't work, you could just dig into that folder directly and update the permissions.
Something like this should work