我正试图在Zurb基金会网站中加入Velocity.js。但是,当我尝试构建网站时,我在webpack中遇到了构建错误。
为了确保它与我最初工作的网站无关,我创建了一个新的安装。两者似乎都有同样的问题。我在配置中遗漏了什么,或者为什么会出现以下错误?
app.js
import $ from 'jquery';
import whatInput from 'what-input';
import Velocity from 'velocity-animate';
import 'velocity-animate/velocity.ui';
window.$ = $;
import Foundation from 'foundation-sites';
// If you want to pick and choose which modules to include, comment out
the above and uncomment
// the line below
//import './lib/foundation-explicit-pieces';
$(document).foundation();
错误:
[10:12:24] Error in plugin 'webpack-stream'
Message:
./~/velocity-animate/velocity.ui.js
Module not found: Error: Can't resolve 'velocity' in '/Users/user/Sites/design/test/node_modules/velocity-animate'
resolve 'velocity' in '/Users/user/Sites/design/test/node_modules/velocity-animate'
Parsed request is a module
using description file: /Users/user/Sites/design/test/node_modules/velocity-animate/package.json (relative path: .)
Field 'browser' doesn't contain a valid alias configuration
after using description file: /Users/user/Sites/design/test/node_modules/velocity-animate/package.json (relative path: .)
resolve as module
/Users/user/Sites/design/test/node_modules/velocity-animate/node_modules doesn't exist or is not a directory
/Users/user/Sites/design/test/node_modules/node_modules doesn't exist or is not a directory
/Users/user/Sites/design/node_modules doesn't exist or is not a directory
/Users/user/Sites/node_modules doesn't exist or is not a directory
/Users/node_modules doesn't exist or is not a directory
/node_modules doesn't exist or is not a directory
looking for modules in /Users/user/Sites/design/test/node_modules
using description file: /Users/user/Sites/design/test/package.json (relative path: ./node_modules)
Field 'browser' doesn't contain a valid alias configuration
after using description file: /Users/user/Sites/design/test/package.json (relative path: ./node_modules)
using description file: /Users/user/Sites/design/test/package.json (relative path: ./node_modules/velocity)
no extension
Field 'browser' doesn't contain a valid alias configuration
/Users/user/Sites/design/test/node_modules/velocity doesn't exist
.js
Field 'browser' doesn't contain a valid alias configuration
/Users/user/Sites/design/test/node_modules/velocity.js doesn't exist
.json
Field 'browser' doesn't contain a valid alias configuration
/Users/user/Sites/design/test/node_modules/velocity.json doesn't exist
as directory
/Users/user/Sites/design/test/node_modules/velocity doesn't exist
looking for modules in /Users/user/node_modules
No description file found
Field 'browser' doesn't contain a valid alias configuration
No description file found
no extension
Field 'browser' doesn't contain a valid alias configuration
/Users/user/node_modules/velocity doesn't exist
.js
Field 'browser' doesn't contain a valid alias configuration
/Users/user/node_modules/velocity.js doesn't exist
.json
Field 'browser' doesn't contain a valid alias configuration
/Users/user/node_modules/velocity.json doesn't exist
as directory
/Users/user/node_modules/velocity doesn't exist
[/Users/user/Sites/design/test/node_modules/velocity-animate/node_modules]
[/Users/user/Sites/design/test/node_modules/node_modules]
[/Users/user/Sites/design/node_modules]
[/Users/user/Sites/node_modules]
[/Users/node_modules]
[/node_modules]
[/Users/user/node_modules/package.json]
[/Users/user/Sites/design/test/node_modules/velocity]
[/Users/user/Sites/design/test/node_modules/velocity.js]
[/Users/user/node_modules/velocity/package.json]
[/Users/user/Sites/design/test/node_modules/velocity.json]
[/Users/user/node_modules/velocity]
[/Users/user/Sites/design/test/node_modules/velocity]
[/Users/user/node_modules/velocity.js]
[/Users/user/node_modules/velocity.json]
[/Users/user/node_modules/velocity]
@ ./~/velocity-animate/velocity.ui.js 19:2-31
@ ./src/assets/js/app.js
@ multi ./src/assets/js/app.js
Details:
domain: [object Object]
domainThrown: true
答案 0 :(得分:0)
根据this open issue,您无法以这种方式导入速度。 This comment现在说要这样做:
window.Velocity = require('velocity-animate');
require('velocity-animate/velocity.ui');