Rollup build error: Cannot call a namespace ('io')


#1

Hi I have a problem with build when use socket.io-client.
(in previous version ionic2, before a month same code worked perfect).

[12:19:05] ionic-app-scripts 0.0.30
[12:19:05] build prod started …
[12:19:05] clean started …
[12:19:05] clean finished in 14 ms
[12:19:05] copy started …
[12:19:05] ngc started …
[12:19:05] lint started …
[12:19:05] copy finished in 119 ms
[12:19:06] lint finished in 1.12 s
[12:19:20] ngc finished in 15.30 s
[12:19:20] bundle prod started …
[12:19:27] bundle prod failed: Cannot call a namespace (‘io’)
[12:19:27] Error: Cannot call a namespace (‘io’)
at error (//node_modules/rollup/dist/rollup.js:5404:12)
at CallExpression.bind (/
/node_modules/rollup/dist/rollup.js:5837:5)
at //node_modules/rollup/dist/rollup.js:5149:50
at AssignmentExpression.eachChild (/
/node_modules/rollup/dist/rollup.js:5166:5)
at AssignmentExpression.bind (//node_modules/rollup/dist/rollup.js:5149:7)
at AssignmentExpression.bind (/
/node_modules/rollup/dist/rollup.js:5509:23)
at //node_modules/rollup/dist/rollup.js:5149:50
at ExpressionStatement.eachChild (/
/node_modules/rollup/dist/rollup.js:5166:5)
at ExpressionStatement.bind (//node_modules/rollup/dist/rollup.js:5149:7)
at BlockStatement.bind (/
/node_modules/rollup/dist/rollup.js:5615:9)
Error running ionic app script “build”: Error: Cannot call a namespace (‘io’)

npm ERR! Linux 4.4.0-38-generic
npm ERR! argv “/.nvm/versions/node/v6.7.0/bin/node” “/.nvm/versions/node/v6.7.0/lib/node_modules/npm/bin/npm-cli.js” “run-script” "build"
npm ERR! node v6.7.0
npm ERR! npm v3.10.3
npm ERR! code ELIFECYCLE
npm ERR! ionic-hello-world@ build: ionic-app-scripts build
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ionic-hello-world@ build script ‘ionic-app-scripts build’.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the ionic-hello-world package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! ionic-app-scripts build
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs ionic-hello-world
npm ERR! Or if that isn’t available, you can get their info via:
npm ERR! npm owner ls ionic-hello-world
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:

IONIC INFO:
Cordova CLI: 6.3.1
Ionic Framework Version: 2.0.0-rc.0
Ionic CLI Version: 2.1.0-beta.3
Ionic App Lib Version: 2.1.0-beta.1
OS: Distributor ID: Ubuntu Description: Ubuntu 16.04.1 LTS
Node Version: v6.7.0

Imports in provider:

import * as io from 'socket.io-client';

Package.json:
{
“name”: “ionic-hello-world”,
“author”: “Ionic Framework”,
“homepage”: “http://ionicframework.com/”,
“private”: true,
“scripts”: {
“build”: “ionic-app-scripts build”,
“watch”: “ionic-app-scripts watch”,
“serve:before”: “watch”,
“emulate:before”: “build”,
“deploy:before”: “build”,
“build:before”: “build”,
“run:before”: “build”
},
“dependencies”: {
"@ionic/storage": “^1.0.3”,
“ionic-angular”: “^2.0.0-rc.0”,
“ionic-native”: “^2.0.3”,
“ionicons”: “^3.0.0”,
“socket.io-client”: “^1.5.0”
},
“devDependencies”: {
"@ionic/app-scripts": “latest”,
“typescript”: “^2.0.3”
},
“description”: “P2PTrade: An Ionic project”,
“cordovaPlugins”: [
“cordova-plugin-device”,
“cordova-plugin-console”,
“cordova-plugin-whitelist”,
“cordova-plugin-splashscreen”,
“cordova-plugin-statusbar”,
“ionic-plugin-keyboard”
],
“cordovaPlatforms”: []
}

typings.json
{
“dependencies”: {},
“devDependencies”: {},
“globalDependencies”: {
“es6-shim”: “registry:dt/es6-shim#0.31.2+20160602141504”,
“require”: “registry:dt/require#2.1.20+20160316155526”,
“socket.io-client”: “registry:dt/socket.io-client#1.4.4+20160317120654”
}
}

Any idea???

A lot of thanks!
Vadim.


#2

Try changing the wildcard import to something like import io from 'io';.


#3

You are right!!! A LOT OF THANKS!!!

import io from 'socket.io-client';
instead
import * as io from ‘socket.io-client’;

it solved it…


#4

If possible can you please provide details for me its still not working