Npm run build shows error


#1

hello,
i just open a new project in ionic 2 and i get errors
C:\Users\adirz\myapps\todo>npm run build

ionic-hello-world@ build C:\Users\adirz\myapps\todo
ionic-app-scripts build

[19:21:56]  ionic-app-scripts 0.0.36
[19:21:56]  build prod started ...
[19:21:56]  clean started ...
[19:21:56]  clean finished in 1 ms
[19:21:56]  copy started ...
[19:21:56]  ngc started ...
[19:21:56]  copy finished in 79 ms
[19:21:56]  lint started ...
[19:21:58]  lint finished in 1.39 s
[19:22:00]  ngc finished in 3.80 s
[19:22:00]  bundle started ...
[19:22:01]  bundle failed: Could not resolve './app.module.ngfactory' from C:\Users\adirz\myapps\todo\.tmp\app\main.prod.ts
[19:22:01]  ionic-app-script task: "build"
[19:22:01]  Error: Could not resolve './app.module.ngfactory' from C:\Users\adirz\myapps\todo\.tmp\app\main.prod.ts

npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "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:
npm ERR!     C:\Users\adirz\myapps\todo\npm-debug.log

C:\Users\adirz\myapps\todo>

#2

I am also facing this issue. Is your ionic serve working? For me, it is working.


#3

@codestellar i found solution
copy this tsconfig.json

{
“compilerOptions”: {
“allowSyntheticDefaultImports”: true,
“declaration”: true,
“emitDecoratorMetadata”: true,
“experimentalDecorators”: true,
“lib”: [
“dom”,
“es2015”
],
“module”: “es2015”,
“moduleResolution”: “node”,
“target”: “es5”
},
“exclude”: [
“node_modules”
],
“compileOnSave”: false,
“atom”: {
“rewriteTsconfig”: false
}
}


#4

Thanks, I was running into the issue too, and this fixed it.


#5

I am already having this tsconfig.json :frowning:

It is giving cannot find module ngfactory


#6

did you change the tsconfig?


#7

So the editor will show that error because that file is generated dynamically.
It’s safe to ignore that error :smile:

As for the tsconfig, that has been fixed for now as well.


#8

I deleted the node_modules folder and ran npm install and it fixed the problem for me.


#9

Same here, I’ve been doing some cross-platform (windows/linux) dev using the same src files. Apparently that’s was the problem.