larsgw / citation.js

Citation.js converts formats like BibTeX, Wikidata JSON and ContentMine JSON to CSL-JSON to convert to other formats like APA, Vancouver and back to BibTeX.
https://citation.js.org/
MIT License
219 stars 30 forks source link

Module not found error on build #183

Closed TanguyHefnaoui closed 5 years ago

TanguyHefnaoui commented 5 years ago

Citation.js v 0.4.5 Node v 8.12.0 OS Windows 10 I am working using vuejs.

I didn't do anything yet. I just try to include citation.js const Cite = require('citation-js'); in one of my vue component and run webpack to compile my files.

I get several errors out of it:

These relative modules were not found:

* ./config in ./node_modules/@citation-js/plugin-wikidata/lib-mjs/index.js, ./node_modules/@citation-js/plugin-wikidata/lib-mjs/id.js and 1 other
* ./props in ./node_modules/@citation-js/plugin-wikidata/lib-mjs/entity.js
* ./types in ./node_modules/@citation-js/plugin-wikidata/lib-mjs/prop.js

WARNING in ./node_modules/@citation-js/plugin-wikidata/lib-mjs/index.js
95:11-29 "export 'parsePropType' (imported as 'prop') was not found in './prop'
 @ ./node_modules/@citation-js/plugin-wikidata/lib-mjs/index.js
 @ ./node_modules/citation-js/index.js
 @ ./node_modules/babel-loader/lib?{"cacheDirectory":true,"presets":[["env",{"modules":false,"targets":{"browsers":["> 2%"],"uglify":true}}]],"plugins":["transform-object-rest-spread",["transform-runtime",{"polyfill":false,"helpers":false}]]}!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./resources/assets/js/components/DocumentsLazyLoad.vue
 @ ./resources/assets/js/components/DocumentsLazyLoad.vue
 @ ./resources/assets/js/app.js
 @ multi ./resources/assets/js/app.js ./resources/assets/sass/app.scss

ERROR in ./node_modules/@citation-js/plugin-wikidata/lib-mjs/index.js
Module not found: Error: Can't resolve './config' in '/home/vagrant/code/IPTeamwork/node_modules/@citation-js/plugin-wikidata/lib-mjs'
 @ ./node_modules/@citation-js/plugin-wikidata/lib-mjs/index.js 7:0-30
 @ ./node_modules/citation-js/index.js
 @ ./node_modules/babel-loader/lib?{"cacheDirectory":true,"presets":[["env",{"modules":false,"targets":{"browsers":["> 2%"],"uglify":true}}]],"plugins":["transform-object-rest-spread",["transform-runtime",{"polyfill":false,"helpers":false}]]}!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./resources/assets/js/components/DocumentsLazyLoad.vue
 @ ./resources/assets/js/components/DocumentsLazyLoad.vue
 @ ./resources/assets/js/app.js
 @ multi ./resources/assets/js/app.js ./resources/assets/sass/app.scss

ERROR in ./node_modules/@citation-js/plugin-wikidata/lib-mjs/id.js
Module not found: Error: Can't resolve './config' in '/home/vagrant/code/IPTeamwork/node_modules/@citation-js/plugin-wikidata/lib-mjs'
 @ ./node_modules/@citation-js/plugin-wikidata/lib-mjs/id.js 2:0-30
 @ ./node_modules/@citation-js/plugin-wikidata/lib-mjs/index.js
 @ ./node_modules/citation-js/index.js
 @ ./node_modules/babel-loader/lib?{"cacheDirectory":true,"presets":[["env",{"modules":false,"targets":{"browsers":["> 2%"],"uglify":true}}]],"plugins":["transform-object-rest-spread",["transform-runtime",{"polyfill":false,"helpers":false}]]}!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./resources/assets/js/components/DocumentsLazyLoad.vue
 @ ./resources/assets/js/components/DocumentsLazyLoad.vue
 @ ./resources/assets/js/app.js
 @ multi ./resources/assets/js/app.js ./resources/assets/sass/app.scss

ERROR in ./node_modules/@citation-js/plugin-wikidata/lib-mjs/prop.js
Module not found: Error: Can't resolve './config' in '/home/vagrant/code/IPTeamwork/node_modules/@citation-js/plugin-wikidata/lib-mjs'
 @ ./node_modules/@citation-js/plugin-wikidata/lib-mjs/prop.js 20:0-30
 @ ./node_modules/@citation-js/plugin-wikidata/lib-mjs/index.js
 @ ./node_modules/citation-js/index.js
 @ ./node_modules/babel-loader/lib?{"cacheDirectory":true,"presets":[["env",{"modules":false,"targets":{"browsers":["> 2%"],"uglify":true}}]],"plugins":["transform-object-rest-spread",["transform-runtime",{"polyfill":false,"helpers":false}]]}!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./resources/assets/js/components/DocumentsLazyLoad.vue
 @ ./resources/assets/js/components/DocumentsLazyLoad.vue
 @ ./resources/assets/js/app.js
 @ multi ./resources/assets/js/app.js ./resources/assets/sass/app.scss

ERROR in ./node_modules/@citation-js/plugin-wikidata/lib-mjs/entity.js
Module not found: Error: Can't resolve './props' in '/home/vagrant/code/IPTeamwork/node_modules/@citation-js/plugin-wikidata/lib-mjs'
 @ ./node_modules/@citation-js/plugin-wikidata/lib-mjs/entity.js 24:0-46
 @ ./node_modules/@citation-js/plugin-wikidata/lib-mjs/index.js
 @ ./node_modules/citation-js/index.js
 @ ./node_modules/babel-loader/lib?{"cacheDirectory":true,"presets":[["env",{"modules":false,"targets":{"browsers":["> 2%"],"uglify":true}}]],"plugins":["transform-object-rest-spread",["transform-runtime",{"polyfill":false,"helpers":false}]]}!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./resources/assets/js/components/DocumentsLazyLoad.vue
 @ ./resources/assets/js/components/DocumentsLazyLoad.vue
 @ ./resources/assets/js/app.js
 @ multi ./resources/assets/js/app.js ./resources/assets/sass/app.scss

ERROR in ./node_modules/@citation-js/plugin-wikidata/lib-mjs/prop.js
Module not found: Error: Can't resolve './types' in '/home/vagrant/code/IPTeamwork/node_modules/@citation-js/plugin-wikidata/lib-mjs'
 @ ./node_modules/@citation-js/plugin-wikidata/lib-mjs/prop.js 21:0-28
 @ ./node_modules/@citation-js/plugin-wikidata/lib-mjs/index.js
 @ ./node_modules/citation-js/index.js
 @ ./node_modules/babel-loader/lib?{"cacheDirectory":true,"presets":[["env",{"modules":false,"targets":{"browsers":["> 2%"],"uglify":true}}]],"plugins":["transform-object-rest-spread",["transform-runtime",{"polyfill":false,"helpers":false}]]}!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./resources/assets/js/components/DocumentsLazyLoad.vue
 @ ./resources/assets/js/components/DocumentsLazyLoad.vue
 @ ./resources/assets/js/app.js
 @ multi ./resources/assets/js/app.js ./resources/assets/sass/app.scss

I also tried calling citation.js using import Cite from 'citation-js but get the same errors.

larsgw commented 5 years ago

You can probably ignore this warning:

WARNING in ./node_modules/@citation-js/plugin-wikidata/lib-mjs/index.js
95:11-29 "export 'parsePropType' (imported as 'prop') was not found in './prop'

That's a typo that will be fixed in the next release, but it's only used when exposing an internal API, which you probably don't use (the @wikidata/type input format).

As for the errors, those are all JSON files so either they somehow were removed from the directory, Webpack/Vue doesn't resolve the file properly or it doesn't support loading JSON files. However, with a clean Webpack (no Vue) install it works fine for me.

TanguyHefnaoui commented 5 years ago

You are right, my webpack was not resolving json files. I fixed the problem. Thanks