我正在使用musixmatch-sdk中的api,并通过使用webpack构build项目时webpack 。 我正在使用webpack 2 , react , node 。 musixmatch网站上的默认import是: var MusixmatchApi = require('../../build/javascript-client/src/index'); 但是,这并没有工作,并得到这个错误: ERROR in ./build/javascript-client/src/index.js<br/> Module not found: Error: Can't resolve 'ApiClient' in '/Users/myname/lyrix/build/javascript-client/src'<br/> @ ./build/javascript-client/src/index.js 28:4-2099<br/> @ ./src/server.js 所以我写了一个绝对path如下: const MusixmatchApi = require(path.join(__dirname,'../build/javascript-client/src/index')); 这工作在webpack开发模式,但我得到这个警告: WARNING in ./src/server.js 33:20-102 Critical dependency: the request of a dependency is an expression @ ./src/server.js 所以,如果我想build立生产项目,我得到的错误: […]
我尝试使用Webpack来打包我的React代码。 然后我尝试使用请求从网站获取一些信息。 这是我的JS代码的一部分 rp({url:'http://int.dpool.sina.com.cn/iplookup',encoding:null}) .then((html) => { this.setState({data:"sucess"}) }) .catch((err) =>{ this.setState({data:err.toString()}) }) 我使用rp,这是request-promise(request with promise),我试图通过this.state.data显示结果。 代码运行在节点(没有反应和webpack),我成功地访问数据。 如果我使用Webpack来打包它,它显示错误:RequestError:TypeError:无法获取。 我想在使用webpack之后,互联网有一些问题。 这是我的webpack.config.js let path = require('path'); module.exports = { entry: './App/app.js', output: { path: path.join(__dirname, '/dest'), filename: 'app.js' }, resolve: { extensions: ['.js', '.jsx', '.css'] }, module: { loaders: [ { test: /\.js|jsx$/, loaders: ['babel-loader'], exclude: /node_modules/ […]
我正在一个网站上的Gulp和Webpack生成所有的js文件。 问题是,在index.html中导入的时候,由webpack生成的文件Vendor.js(捆绑来自node_modules文件夹的JQuery和Bootstrap )不能正常工作,因此我必须包含jquery.js和bootstrap.js手动的文件,我不想。 当我打开生成的Vendor.js文件,它看起来像它有bootstrap.js和jquery.js,但它不工作:( 在这里你可以看到文件夹结构: webpack.config.js var path = require('path'); module.exports = { entry: { App: "./app/js/App.js", Vendor: "./app/js/Vendor.js" }, output: { path: path.resolve(__dirname, "./app/temp/scripts"), filename: "[name].js" }, module: { loaders: [ { loader: 'babel-loader', query: { presets: ['es2015'] }, test: /\.js$/, exclude: /node_modules/ } ] }, plugins: [ new webpack.ProvidePlugin({ $: 'jquery', jQuery: 'jquery', […]
我有一些*.ts文件,我想join一个bundle.js文件。 要做到这一点,我正在使用webpack version 3.* 。 问题是我想避免导入其他库或Commonjs在捆绑文件中发射。 例如,我有import * as firebase from 'firebase将发射捆绑文件,我想要避免它。 只有我写的文件应该join,比如file1.ts,file2.ts,…。
我正面临着巨大的问题,试图与反应路由器一起实现多个入口点。 目的是实现使用webpack做一些build议由https://github.com/petehunt/webpack-howto 。 到目前为止,我已经把它设置为这样: webpack.config.js entry: { entry1: __dirname + './entry1.jsx', entry2: __dirname + './entry2.jsx' } routes.jsx export default ( <Route path='/' name='app' handler={App}> <DefaultRoute handler={entry1} /> <Route name='entry2' handler={entry2}/> </Route> ); 无论何时运行此代码以在客户端上实例化Router的实例 Router.run(routes, Router.HistoryLocation, (Handler, state) => { React.render(<Handler />, document.getElementById('app')); }); Node.js会尝试在服务器上运行这个代码,因为DOM不可用,所以显然会失败。 它会产生一个错误。 是否有任何适当的方法来实现多入口点与react-router?
我在基于react-starter-kit的项目中运行OpenLayers3 Map时遇到了问题。 我试图添加简单的地图来反应组件。 我所做的是: 运行npm install openlayers 将import ol from 'openlayers'添加到ContactPage.js 创build简单的地图 componentDidMount(){ var map = new ol.Map({ target: 'map', layers: [ new ol.layer.Tile({ source: new ol.source.MapQuest({layer: 'sat'}) }) ], view: new ol.View({ center: ol.proj.transform([37.41, 8.82], 'EPSG:4326', 'EPSG:3857'), zoom: 4 }) }); } 将渲染函数<div id="map" className="map"></div> jsx部分添加<div id="map" className="map"></div> 运行npm start。 我得到一个错误: …\node_modules\openlayers\dist\ol.js:7 module.exports = […]
我第一次使用webpack。 我可以使用什么加载器来加载.node文件? 我正在使用webpack.config.js target:node构build节点 我得到错误…第1行:意外的标记ILLEGAL您可能需要一个适当的加载器来处理这种文件types。
我正在试图让ag-grid与webpack一起工作。 我已经完成了标准的事情,通过添加通过npm的网格,并添加了引用webpack.config这样做: resolve: { alias: {"ag-grid" : path.resolve(__dirname, "./node_modules/ag-grid/dist/ag-grid.js") } 该文件得到解决,并加载到索引文件就好了。 我做了以下的angular度。 angular.module("cs-app", [require("ag-grid").name]); Webpack也parsing这个文件,并被包含并加载,但是当我运行应用程序,我得到以下错误。 [$injector:modulerr] Failed to instantiate module angularGridGlobalFunction due to: [$injector:nomod] Module 'angularGridGlobalFunction' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument. 我无法在ag-grid.js中find名称angularGridGlobalFunction,但是当我注释掉对ag-grid的引用时,该应用程序工作得很好。 […]
你好,我尝试从我的脚本脚本需要angular度,我得到这个错误: error TS2307: Cannot find module 'angular'. 这是我的webpackconfiguration文件: context: __dirname + '/client/js', entry: './script.ts', output: { filename: 'build.js', path: options.BUILD ? 'dist' : 'dev' }, module: { loaders: [ {test: /\.ts(x?)$/, loader: 'babel-loader!ts-loader'} ] } 编辑: 然后,在我的script.ts文件中,我这样做: import angular from 'angular'; 甚至var angular = require('angular'); 给了我相同的结果 我没有任何tsconfig.json文件 谢谢 !
我有C:/ Users / user / AppData / Roaming / npm / node_modulespath中的所有节点模块。 然后,我正在尝试为我的脚本webpack添加包含babel和babel-presets的node_modules。 我的webpack.config.js module.exports = { context: './scripts', entry: ['./main', './2.jsx'], output: { path: '../scripts', filename: 'bundle.js', }, resolve: { modulesDirectories: ['C:/Users/user/AppData/Roaming/npm/node_modules'] }, resolveLoader: { root: 'C:/Users/user/AppData/Roaming/npm/node_modules' }, module: { loaders: [{ test: /\.jsx?$/, loader: 'babel-loader', include: 'C:/Users/user/AppData/Roaming/npm/node_modules', exclude: /(node_modules|bower_components)/, query: { presets: ['es2015', […]