Reputation: 104
I've installed the third party library https://www.npmjs.com/package/scroll-into-view into my Aurelia CLI project using:
npm install --save scroll-into-view
I've added the following to the dependencies array in aurelia.json
:
{
"name": "scroll-into-view",
"path": "../node_modules/scroll-into-view",
"main": "scrollIntoView"
}
I've added the following to the component I want to make use of the library:
import * as scrollIntoView from "scroll-into-view";
When I execute au run --watch
I receive a long list of errors, repeating a version of the following:
Error: ENOENT: no such file or directory, open 'C:\src\choiceswizard\src\node_modules\raf.js'
at Object.fs.openSync (fs.js:558:18)
at Object.fs.readFileSync (fs.js:468:33)
at Object.exports.readFileSync (C:\src\choiceswizard\node_modules\aurelia-cli\lib\file-system.js:49:13)
at fileRead (C:\src\choiceswizard\node_modules\aurelia-cli\lib\build\bundled-source.js:83:31)
at Object.context.fileRead (C:\src\choiceswizard\node_modules\aurelia-cli\lib\build\amodro-trace\lib\loader\Loader.js:176:18)
at Object.context.load (C:\src\choiceswizard\node_modules\aurelia-cli\lib\build\amodro-trace\lib\loader\Loader.js:357:30)
at Module.load (eval at <anonymous> (C:\src\choiceswizard\node_modules\aurelia-cli\lib\build\amodro-trace\lib\loader\Loader.js:14:1), <anonymous>:832:29)
at Module.fetch (eval at <anonymous> (C:\src\choiceswizard\node_modules\aurelia-cli\lib\build\amodro-trace\lib\loader\Loader.js:14:1), <anonymous>:822:66)
at Module.check (eval at <anonymous> (C:\src\choiceswizard\node_modules\aurelia-cli\lib\build\amodro-trace\lib\loader\Loader.js:14:1), <anonymous>:854:30)
at Module.enable (eval at <anonymous> (C:\src\choiceswizard\node_modules\aurelia-cli\lib\build\amodro-trace\lib\loader\Loader.js:14:1), <anonymous>:1173:22)
errno: -4058,
code: 'ENOENT',
syscall: 'open',
path: 'C:\\src\\choiceswizard\\src\\node_modules\\raf.js',
moduleTree: [ 'scroll-into-view/scrollIntoView' ],
fileName: 'C:/src/choiceswizard/node_modules/scroll-into-view/scrollIntoView.js'
This informed me that scroll-into-view
has a dependency on raf
https://www.npmjs.com/package/raf while raf
has its own dependencies and likely so-on.
Notice that the dependencies are being looked for in root of the C:\src\choiceswizard\src\node_modules\
folder and not in the individual module folders e.g. C:\src\choiceswizard\src\node_modules\raf
.
Also, upon further experimentation I discovered that raf
uses index.js
as its entry-point and as such what appears to be an assumption being made that raf.js
is the name of the file is incorrect.
It seems to me like Aurelia CLI is not parsing the package.json of each dependency in the hierarchy and loading them accordingly. I could also be horribly misunderstanding the issue.
Does anyone have any insight that might help me use scroll-into-view
in my project?
Upvotes: 0
Views: 451
Reputation: 10887
This package has a dependency which itself has a dependency.
Add the following to the dependencies
section of the vendor-bundle
config in your aurelia.json
file and you'll be good to go:
"performance-now",
"raf",
"scroll-into-view"
Upvotes: 1