OS: macOS 10.14 Mojave
node -v: v10.15.0
npm -v: 6.5.0
nvm --version: 0.34.0
@11ty/eleventy: 0.7.1
When I run eleventy I get
Problem writing Eleventy templates: (more in DEBUG output)
Cannot find module 'viperhtml' (Error):
Error: Cannot find module 'viperhtml'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
at Function.Module._load (internal/modules/cjs/loader.js:507:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object.(/Users/me/mx41/blog/mx41.github.com/node_modules/@11ty/eleventy/test/stubs/viperhtml.11ty.js:1:81)
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)
Contents of package.json:
{
"name": "mx41.github.com",
"version": "1.0.0",
"description": "",
"main": "index.html",
"scripts": {
"start": "eleventy --serve --watch",
"build": "eleventy",
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git@github-mx41:mx41/mx41.github.com.git"
},
"author": "MX41",
"license": "MIT",
"devDependencies": {
"@11ty/eleventy": "^0.7.1"
}
}
I have tried npm install and removal of node_modules a few times, but it unfortunately did not help.
node is managed by nvm
Hmm, just as info that module is declared in devDependencies and used by the tests. It is not in the normal execution path of eleventy.
Hmm, just as info that module is declared in devDependencies and used by the tests. It is not in the normal execution path of eleventy.
I'm afraid I don't know what you mean, what would be the normal execution path?
What's curious, sometimes there is another missing dependency error:
Problem writing Eleventy templates: (more in DEBUG output)
Cannot find module 'vue' (Error):
Error: Cannot find module 'vue'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
at Function.Module._load (internal/modules/cjs/loader.js:507:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object.(/Users/me/mx41/blog/mx41.github.com/node_modules/@11ty/eleventy/test/stubs/vue-layout.11ty.js:1:75)
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)
Processed 0 files in 3.26 seconds
Though most of the time it is the viperhtml one.
@mx41 That was probably meant as a general info regarding the issue. It means that running Eleventy like you do (probably via npm run build, right?) does not run the tests; hence, the file producing the error should not be executed (because it鈥檚 a test file!) and therefore, no error should be produced.
Turning this around, this kind of looks like the tests are being run indeed. Super very odd.
@mx41 That was probably meant as a general info regarding the issue. It means that running Eleventy like you do (probably via
npm run build, right?)
Yes, that is correct.
does not run the tests; hence, the file producing the error should not be executed (because it鈥檚 a test file!) and therefore, no error should be produced.
Turning this around, this kind of looks like the tests are being run indeed. Super very odd.
Now I get you, thanks!
Yes, that is strange indeed...
Maybe environment variables that are not set right?
Can you make your project source code available somewhere?
Can you make your project source code available somewhere?
@mx41 If you鈥檙e able to do so, I can run it on my Windows machine when I鈥檓 back.
Can you make your project source code available somewhere?
Sure, it will be hosted on GitHub Pages:
https://github.com/mx41/mx41.github.com
So I just tried creating an index.md test file and it did what it was supposed to do... Strange.
Output:
eleventy
Writing _site/index.html from ./index.html.
Writing _site/README/index.html from ./README.md.
Writing _site/index.html from ./index.md.
Processed 3 files in 0.17 seconds
EDIT: Removing the index.md after this successful run and trying npm run build yields no error anymore.
Ah, okay. I think I know what happened now. I don鈥檛 think adding index.md did anything but adding node_modules into your .gitignore might have fixed it. If your .gitignore file was empty, eleventy may have been trying to process your node_modules (which had eleventy templates inside of it, including the viperhtml one).
Normally, if a project is missing a .gitignore file, we make it a special case to ignore node_modules but if your .gitignore was empty you鈥檇 run into this case.
We may need to make this special case smarter to check if .gitignore is empty or not.
@zachleat Should we not flat out ignore contents of a node_modules directory in the project root?
Yeah maybe, hmm. That'd be a major version change though.
And would also need an escape hatch (configuration method)
Just to confirm, I was getting a similar error but the module was vue. Once I added node_modules to my .gitignore it all worked as expected.
I鈥檝e filed this recommendation at #383, please upvote there!
This is an automated message to let you know that a helpful response was posted to your issue and for the health of the repository issue tracker the issue will be closed. This is to help alleviate issues hanging open waiting for a response from the original poster.
If the response works to solve your problem鈥攇reat! But if you鈥檙e still having problems, do not let the issue鈥檚 closing deter you if you have additional questions! Post another comment and I will reopen the issue. Thanks!
Most helpful comment
Ah, okay. I think I know what happened now. I don鈥檛 think adding
index.mddid anything but addingnode_modulesinto your.gitignoremight have fixed it. If your.gitignorefile was empty, eleventy may have been trying to process yournode_modules(which had eleventy templates inside of it, including the viperhtml one).Normally, if a project is missing a
.gitignorefile, we make it a special case to ignorenode_modulesbut if your.gitignorewas empty you鈥檇 run into this case.