angular: Angular CLI build fails with allowJs: true fails when there is javascript file in src folder

I’m submitting a…


[x] Regression (a behavior that used to work and stopped working in a new release)

Current behavior

ng serve fails if there is any javascript file in src directory

Expected behavior

build should work just fine, last working version angular 4.x

Minimal reproduction of the problem with instructions

create new project with ng new projectname modify the tsconfig.json to set "allowJs": true create new file .js file in src/app run ng serve

What is the motivation / use case for changing the behavior?

Environment


Angular version: 5.1.1


Browser:
- [ x] Chrome (desktop) version XX
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
 
For Tooling issues:
- Node version: 8.9.3
- Platform:  Windows 10 

Others:

@angular/cli 1.6.1

it’s not fixed by related bug https://github.com/angular/angular/issues/19757#issuecomment-352490677

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 15
  • Comments: 41 (4 by maintainers)

Commits related to this issue

Most upvoted comments

Any idea as to when this issue will be resolved? I have to update my project to material 5 which depends on ng5 which fails on build with allowJs.

@ameya after you get this error you must save any .ts file to start the transpile process again, then you’ll get no error.

  1. create a directory (ex chartist-plugins )
  2. copy your js file into chartist-plugins directory
  3. cd path/to/chartist-plugins
  4. run npm init (just enter for all questions)
  5. cd path/to/your/angular/project
  6. install-local /path/to/the/chartist-plugins/directory (assumed you have already installed install-local)
  7. import the package like other npm packages in your project
  8. remove allowJs from tsconfig

But how to run it when using CI like jenkins? Makes no sense to me.

@elvisfernandes thanks for the help we can work with the workaround now. I missed out the purpose of --watch=auto by @neoncube2. Thanks for the help 😃

Hi @hansl, is there any update on this issue is resolved? As we already have a production-ready application build from angular 5 downgrading to angular 4 is not an option for us. Because of this one blocker, we are thinking of breaking only the external js dependant part into angular 4 application that will be used in angular 5 application via html iFrames. Any ETA date so we can hold on to bug to avoid unnecessary extra work?

Anyone has a workaround for Angular 5. Install local does not work on my windows machine. link. @vladimiry workaround also did not work out. ERROR in src/app/jsplumb/jsplumb.component.ts(7,16): error TS2304: Cannot find name 'require'.

@hansl is there any ETA on this PR it has been a blocker in my project.

I’ve got this issue with an imported JS file outside the src directory too: ERROR in error TS5055: Cannot write file '<JS FILE PATH>' because it would overwrite input file.