Closed tarranjones closed 7 years ago
I cannot reproduce. Just tried with latest yo
and generator-nm
:
create package.json
create index.js
create license
create readme.md
create test.js
create .editorconfig
create .gitattributes
create .gitignore
create .travis.yml
Never experienced this bug.
I also used a fresh install of yo
and generator-nm
, heres the full output
Tarrans-iMac:tarranjones tarran$ node -v
v5.12.0
Tarrans-iMac:tarranjones tarran$ npm -v
3.8.6
Tarrans-iMac:tarranjones tarran$ yo --version
1.8.5
Tarrans-iMac:tarranjones tarran$ npm list -g generator-nm
/Users/tarran/.nvm/versions/node/v5.12.0/lib
├── generator-nm@3.2.0
├── UNMET PEER DEPENDENCY rxjs@~5.0.0-beta.12
└── UNMET PEER DEPENDENCY zone.js@~0.6.21
npm ERR! peer dep missing: rxjs@~5.0.0-beta.12, required by angular2-universal@2.1.0-rc.1
npm ERR! peer dep missing: zone.js@~0.6.21, required by angular2-universal@2.1.0-rc.1
Tarrans-iMac:tarranjones tarran$ mkdir generator-nm-test
Tarrans-iMac:tarranjones tarran$ cd generator-nm-test
Tarrans-iMac:generator-nm-test tarran$ yo nm
? What do you want to name your module? generator-nm-test
? What is your module description? My lovely module
? What is your GitHub username? tarranjones
? What is the URL of your website? http://tarranjones.com
? Do you need a CLI? No
? Do you need code coverage? No
Initialized empty Git repository in /Users/tarran/github.com/tarranjones/generator-nm-test/.git/
create index.js
create license
create readme.md
create test.js
create .editorconfig/editorconfig
create .gitattributes/gitattributes
create .gitignore/gitignore
create .travis.yml/travis.yml
create package.json/_package.json
I'm all done. Running npm install for you to install the required dependencies. If this fails, try running the command yourself.
npm WARN eisdir EISDIR: illegal operation on a directory, read
npm WARN generator-nm-test No description
npm WARN generator-nm-test No repository field.
npm WARN generator-nm-test No README data
npm WARN generator-nm-test No license field.
I started seeing something even crazier today. Seems related.
events.js:160
throw er; // Unhandled 'error' event
^
TypeError: Path must be a string. Received [ '/Users/sholladay/Code/personal/gen-test/editorconfig',
'/Users/sholladay/Code/personal/gen-test/editorconfig/**' ]
at assertPath (path.js:7:11)
at Object.dirname (path.js:1324:5)
at Object.exports.getCommonPath (/Users/sholladay/Code/personal/generator-nm/node_modules/mem-fs-editor/lib/util.js:27:15)
at Array.map (native)
at Object.exports.getCommonPath (/Users/sholladay/Code/personal/generator-nm/node_modules/mem-fs-editor/lib/util.js:16:8)
at EditionInterface.exports.copy (/Users/sholladay/Code/personal/generator-nm/node_modules/mem-fs-editor/lib/actions/copy.js:40:21)
at EditionInterface.module.exports [as move] (/Users/sholladay/Code/personal/generator-nm/node_modules/mem-fs-editor/lib/actions/move.js:4:8)
at mv (/Users/sholladay/Code/personal/generator-nm/app/index.js:98:13)
at prompt.then.props (/Users/sholladay/Code/personal/generator-nm/app/index.js:110:4)
Node: 7.4.0 npm: 4.1.2 yo: 1.8.5 generator-nm: 3.2.0 yeoman-generator: 1.1.0 mem-fs-editor: 3.0.0
The timing is certainly suspicious with the release of yeoman-generator 1.1.0 which upgraded mem-fs-editor.
And for me, at least, I was able to fix it by pinning the version of yeoman-generator
(changing it from ^1.0.1
to 1.0.1
in package.json) followed by rm -rf node_modules && npm install
.
Anyone seeing related weirdness should post their npm ls yeoman-generator mem-fs-editor
.
In case symlinks are affecting this somehow, it is worth noting that instead of a typical npm install -g generator-nm
scenario, I have it set up for hacking with git clone git@github.com:sindresorhus/generator-nm.git && cd generator-nm && npm link && cd ..
.
// @sboudrias
Got the same issue as @sholladay
❯ yo --version
1.8.5
❯ npm --version
4.1.2
❯ node --version
v7.4.0
events.js:160
throw er; // Unhandled 'error' event
^
TypeError: Path must be a string. Received [ '/Users/jjuszczak/Projekte/Privat/tmp-package/editorconfig',
'/Users/jjuszczak/Projekte/Privat/tmp-package/editorconfig/**' ]
at assertPath (path.js:7:11)
at Object.dirname (path.js:1324:5)
at Object.exports.getCommonPath (/usr/local/lib/node_modules/generator-nm/node_modules/mem-fs-editor/lib/util.js:27:15)
at Array.map (native)
at Object.exports.getCommonPath (/usr/local/lib/node_modules/generator-nm/node_modules/mem-fs-editor/lib/util.js:16:8)
at EditionInterface.exports.copy (/usr/local/lib/node_modules/generator-nm/node_modules/mem-fs-editor/lib/actions/copy.js:40:21)
at EditionInterface.module.exports [as move] (/usr/local/lib/node_modules/generator-nm/node_modules/mem-fs-editor/lib/actions/move.js:4:8)
at mv (/usr/local/lib/node_modules/generator-nm/app/index.js:98:13)
at prompt.then.props (/usr/local/lib/node_modules/generator-nm/app/index.js:110:4)
@apertureless does pinning the version of yeoman-generator solve it for you? Change it from ^1.0.1
to 1.0.1
in package.json
, followed by rm -rf node_modules && npm install
.
And what does npm ls mem-fs-editor
print, before and after?
I think I found the issue in mem-fs-editor and I published a fix. Let me know if the issue persists.
I was able to run generator-nm successfully after the fix, so give me more context if this still fails for you: Are you running on a new project? Over an existing project? Versions + OS? etc
@SBoudrias That fixed the crash for me, but now I am seeing the behavior that @tarranjones described. So I guess they were separate issues.
When the generator runs npm install
, I see this:
npm WARN eisdir EISDIR: illegal operation on a directory, read
npm WARN foo No description
npm WARN foo No repository field.
npm WARN foo No README data
npm WARN foo No license field.
It happens because package.json
actually gets generated as a directory, rather than a file. It contains the _package.json
file. Same thing with the dotfiles. Notice the d
directory bit in the permissions below.
Seth-Laptop:foo sholladay$ ls -lAh
total 40
drwxr-xr-x 3 sholladay wheel 102B Jan 29 17:05 .editorconfig
drwxr-xr-x 9 sholladay wheel 306B Jan 29 17:05 .git
drwxr-xr-x 3 sholladay wheel 102B Jan 29 17:05 .gitattributes
drwxr-xr-x 3 sholladay wheel 102B Jan 29 17:05 .gitignore
drwxr-xr-x 3 sholladay wheel 102B Jan 29 17:05 .travis.yml
-rw-r--r-- 1 sholladay wheel 136B Jan 29 17:05 .yo-rc.json
-rw-r--r-- 1 sholladay wheel 231B Jan 29 17:05 index.js
-rw-r--r-- 1 sholladay wheel 1.1K Jan 29 17:05 license
drwxr-xr-x 3 sholladay wheel 102B Jan 29 17:05 package.json
-rw-r--r-- 1 sholladay wheel 500B Jan 29 17:05 readme.md
-rw-r--r-- 1 sholladay wheel 219B Jan 29 17:05 test.js
A .yo-rc.json
file appears in the destination directory and it is the only dotfile spared from becoming a directory. package.json
is the only non-dotfile to suffer from the problem. This corresponds exactly with which files are moved.
Are you running on a new project?
Yes. Here is my repro script.
DIR='/tmp/foo';
rm -rf "$DIR" && mkdir -p "$DIR" && cd "$DIR" && yo nm --skip-install;
I leave all prompts with their defaults.
This is on macOS Sierra 10.12.2 with Terminal.app running bash 4.4.5.
Seth-Laptop:generator-nm sholladay$ npm ls mem-fs-editor
generator-nm@3.2.0 /Users/sholladay/Code/personal/generator-nm
├─┬ yeoman-generator@1.1.0
│ └── mem-fs-editor@3.0.1
└─┬ yeoman-test@1.6.0
└─┬ yeoman-generator@0.24.1
└── mem-fs-editor@2.3.0
Generation works. But as @sholladay pointed out, package.json gets created as a folder
❯ ls package.json
_package.json
@sindresorhus, @SamVerschueren I ran npm test
on generator-nm
The test.beforeEach
function generated the incorrect files for every test.
Initialized empty Git repository in /Users/tarran/github.com/tarranjones/generator-nm/temp/.git/
create index.js
create license
create readme.md
create test.js
create .editorconfig/editorconfig
create .gitattributes/gitattributes
create .gitignore/gitignore
create .travis.yml/travis.yml
create package.json/_package.json
I'm all done. Just run npm install to install the required dependencies.
The only test which I expected to fail was test.serial('generates expected files',
but that in fact passed.
Heres the output.
2 passed
5 failed
CLI option
Error: EISDIR: illegal operation on a directory, read
node_modules/yeoman-assert/index.js:102:19
Function.assert.fileContent (node_modules/yeoman-assert/index.js:98:9)
Test.<anonymous> (test.js:52:9)
nyc option
Error: EISDIR: illegal operation on a directory, read
node_modules/yeoman-assert/index.js:102:19
Function.assert.fileContent (node_modules/yeoman-assert/index.js:98:9)
Test.<anonymous> (test.js:70:9)
coveralls option
Error: EISDIR: illegal operation on a directory, read
node_modules/yeoman-assert/index.js:102:19
Function.assert.fileContent (node_modules/yeoman-assert/index.js:98:9)
Test.<anonymous> (test.js:92:9)
prompts for description
Error: EISDIR: illegal operation on a directory, read
node_modules/yeoman-assert/index.js:102:19
Function.assert.fileContent (node_modules/yeoman-assert/index.js:98:9)
Test.<anonymous> (test.js:120:9)
defaults to superb description
Error: EISDIR: illegal operation on a directory, read
node_modules/yeoman-assert/index.js:102:19
Function.assert.fileContent (node_modules/yeoman-assert/index.js:98:9)
Test.<anonymous> (test.js:136:9)
Ive confirmed that generator-nm
is sending the correct paths to this.fs.move
and
mem-fs-editor
's move
,copy
and commit
methods all seem to be working fine.
I have the same problem, but I think it's related to yeoman generator this.fn.move, I created new yeoman generator and tried that function and It copies to subdirectories.
Release a new mem-fs-editor version that'll hopefully fix this issue. I've been having issue to properly reproduce this bug. I'm not 100% confident it is fixed, so let me know if it is still broken for you.
Woo! That did it for me @SBoudrias. 🎉
The fix is in mem-fs-editor@3.0.2
. It is a patch release, so a simple rm -rf node_modules && npm install
inside of generator-nm
should do the trick.
Seth-Laptop:generator-nm sholladay$ npm ls mem-fs-editor
generator-nm@3.2.0 /Users/sholladay/Code/personal/generator-nm
├─┬ yeoman-generator@1.1.0
│ └── mem-fs-editor@3.0.2
└─┬ yeoman-test@1.6.0
└─┬ yeoman-generator@0.24.1
└── mem-fs-editor@2.3.0
😃
The mv() function is placing files in a subdirectory.
for example
mv('_package.json', 'package.json');
is moving./_package.json'
to./package.json/_package.json
rather than./package.json'
Heres a list of the files which were created for me