ember-cli 2.16.2下使用ember-browserify导入bpmn-js模块报错
Hey there, let's work through this module not found error you're hitting. I've dealt with similar issues using older Ember CLI versions and ember-browserify, so here's a step-by-step breakdown to get things working:
1. Install the compatible ember-browserify version
Ember CLI 2.16.2 doesn't play nicely with the latest ember-browserify releases (which target newer Ember versions). You'll need to stick to the 1.x branch for compatibility:
# Uninstall any existing ember-browserify first npm uninstall ember-browserify --save-dev # Install the version that works with Ember CLI 2.16.2 npm install ember-browserify@1.2.0 --save-dev
2. Double-check your bpmn dependencies are installed correctly
Make sure you've added bpmn-js and bpmn-js-properties-panel as regular project dependencies (not dev dependencies):
npm install bpmn-js bpmn-js-properties-panel --save
Wait for the install to finish, and confirm there are no errors in your terminal output.
3. Fix your import statement in the route
Older ember-browserify versions can struggle with importing entire libraries directly. Instead, import the specific class you need from bpmn-js (like Modeler, the most common use case):
// In app/routes/hello.js import Ember from 'ember'; import BpmnModeler from 'npm:bpmn-js/lib/Modeler'; export default Ember.Route.extend({ init() { this._super(...arguments); // Example usage to test the import const modeler = new BpmnModeler({ container: '#canvas' }); // ... rest of your route logic } });
If you need other components (like the Viewer), adjust the import path to match (e.g., npm:bpmn-js/lib/Viewer).
4. Clear Ember's cache and restart the dev server
Older Ember versions often hold onto stale cache that breaks module resolution. Do this to refresh things:
# Clear Ember's built-in cache ember clear # If that doesn't work, manually delete the tmp folder rm -rf tmp/ # Restart your development server ember serve
5. Verify your dependency setup
Check your package.json to confirm:
ember-browserifyis listed underdevDependencieswith version^1.2.0bpmn-jsandbpmn-js-properties-panelare in thedependenciessection (notdevDependencies)
If you still run into issues, double-check for typos in your import path, and ensure the node_modules/bpmn-js folder exists (if not, re-run npm install to re-install dependencies).
内容的提问来源于stack exchange,提问作者Srinath Prabhu

