Mihail Burduja
Mihail Burduja

Reputation: 3256

mean.io assetmanager.init(... returns JS error

I want to use MEAN.io stack. I did the required initialization. Created the folder, did the npm install, got the libraries.

now in server/config/express.js I have

assetmanager = require('assetmanager'),

and

// Import your asset file
var assets = require('./assets.json');
assetmanager.init({ // this is line 75
    js: assets.js,
    css: assets.css,
    debug: (process.env.NODE_ENV !== 'production'),
    webroot: 'public/public'
});

and this gives me this error:

server/config/express.js:75
assetmanager.init({
             ^
TypeError: Object #<Object> has no method 'init'
    at module.exports (server/config/express.js:75:18)
    at module.exports (server/config/system/bootstrap.js:49:48)
    at Object.<anonymous> (server.js:20:54)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:902:3
[nodemon] app crashed - waiting for file changes before starting...

I have the package installed.

npm info assetmanager version
0.1.3

Upvotes: 2

Views: 1102

Answers (2)

Yonatan Ellman
Yonatan Ellman

Reputation: 286

Farid is correct that assestmanager pushed out an incompatable version.

The mean.io project has since been updated to use the 0.1.2 version. Commit

All new mean.io projects will have the correct version.

For projects that do not work you can either change your package.json or manually run npm install [email protected]

Please note that it is recommended to rather update your package.json to prevent issues when you change environments or go to production.

Upvotes: 2

Farid Nouri Neshat
Farid Nouri Neshat

Reputation: 30410

The author mistakenly published an incompatible version of assetmanager. You can either use version v0.1.2 instead by running npm install [email protected] command.

Or change your code to be compatible with the latest. Check the README for the example.

Upvotes: 6

Related Questions