Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Importing using CommonJS doesn’t work #3788

Closed
martinbean opened this issue Jan 12, 2017 · 2 comments
Closed

[BUG] Importing using CommonJS doesn’t work #3788

martinbean opened this issue Jan 12, 2017 · 2 comments

Comments

@martinbean
Copy link

Expected Behavior

After installing Chart.js via NPM (npm install chart.js --save-dev), to then be able to include it in scripts like this as per the documentation:

var Chart = require('src/chart.js');

Current Behavior

After installing with NPM and adding var Chart = require('src/chart.js'); in my script, I get the following error:

Module not found: Error: Can't resolve 'src/chart.js' in '/path/to/my/project/resources/assets/js/components'

Possible Solution

Not sure, as "main": "src/chart.js" is in package.json

Steps to Reproduce (for bugs)

  1. Run npm install chart.js --save-dev.
  2. Add var Chart = require('src/chart.js'); to a script as per documentation.

Environment

  • Chart.js version: ^2.4.0
  • Browser name and version: N/A
  • Link to your project: N/A
@Jareechang
Copy link
Contributor

I think its suppose to be var Chart = require('chart.js');

can you give that a try @martinbean and see if that works for you ?

Jareechang added a commit to Jareechang/Chart.js that referenced this issue Jan 22, 2017
@etimberg etimberg added this to the Version 2.5 milestone Jan 22, 2017
@etimberg
Copy link
Member

Docs updated in #3815

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants