How to import npm module for client usage with 1.3?

Hey, I’ve removed all my meteor package dependency, but I’ve an issue with one npm module (simpleColorPicker):

Unable to resolve some modules:
"browser.js" in /Users/toto/node_modules/prefix/package.json (web.browser)
Consider running: meteor npm install --save browser.js

The package seems to be written in commonjs.

how I import it:

import colorPicker from 'simple-color-picker';

my package.json:

{
  "name": "toto",
  "version": "1.0.0",
  "description": "",
  "main": "import/routes.js",
  "dependencies": {
    "d3": "^3.5.16",
    "d3-tip": "^0.6.7",
    "jquery": "^2.2.2",
    "meteor-node-stubs": "^0.2.1",
    "moment": "^2.12.0",
    "sidr": "^2.2.1",
    "simple-color-picker": "0.0.9"
  },
  "devDependencies": {},
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC"
}

According to the guide, installing meteor-node-stubs should make the tricks.

Not on my case obviously, and there is no doc on meteor-node-stubs. Doesn’t it bundle automatically front module for us?

Don’t know what’s wrong…

This looks like a bug with the prefix package (which is a dependency of simple-color-picker). The package.json of the prefix package is using the browser field, which points to the packages browser.js file. This file is then excluded however by the files field (which is only allowing index.js).

{
  "name": "prefix",
  "version": "0.2.4",
  "main": "index.js",
  ...
  "browser": "browser.js",
  ...
  "files": ["index.js"]
}

This is why meteor is complaining about not being able to find the browser.js file (it doesn’t exist locally). I’d suggest opening an issue with the prefix project.

Thanks, I will look into that! Didn’t think about this…

No problem - just to add; I’m not 100% sure that files is the issue, but I can verify that the browser.js file is missing from the local prefix package, so I’m assuming it’s something like that. Regardless, the package author should be able to help verify.

Kinda weird, this come from https://github.com/jkroso/prefix#readme. And you’re true, browser.js is missing on my node_modules, but it’s exist on the repo.

It’s like npm didn’t download this file or maybe the module hosted on npm is broken…