So I have the standard folder structure
dist/
src/
where src
has my .ts files and dist
has my .js files.
(I have "outDir":"dist"
in my tsconfig.json file, and "includes"
set to 'src'
).
Note that 'dist' is in my gitignore
file, so it is not in version control, and so when it goes to Travis or CircleCI
, nothing is in the dist
folder until I run tsc
.
Here is the problem - if I run npm install
first - it will fail because I have this in my package.json:
"bin":{
"foo" :"dist/cli.js" // dist/cli.js does not exist yet
}
but if I run tsc
first - tsc will then be missing dependencies that it needs for compilation, which arrive if I run npm install
.
The only thing I can think of to solve this, is to install all the necessary tsc
dependencies first, then run tsc, then run npm install --production
.
However that is not the most convenient thing to do.
Has anyone run into this problem and found a good solution?
If your npm is broken: On Mac or Linux, reinstall npm. Windows: If you're on Windows and you have a broken installation, the easiest thing to do is to reinstall node from the official installer (see this note about installing the latest stable version).
Remove node_modules and package-lock. To solve the issue, try removing the entire node_modules/ folder and the package-lock. json file. Then try running the npm install command again. That may fix the issue.
To solve the npm ERR! Missing script: "start" error, make sure to add a start command to the scripts object in your package. json file and open your shell or IDE in the root directory of your project before running the npm start command.
you need to change that to npm --logevel=error install , and that will suppress the WARN message and Team Foundation Server will stop complaining about it. After waiting on angular 4 to install for an hour, I cancelled it, used this parameter, and it installed in about 10 seconds.
I don't remember having this problem but in at least one case I did something that will work around the issue.
I put an index.js in the root folder that runs the actual dependency in dist. Then the bin that npm looks for is a file that's present, and it shouldn't freak out.
It won't work until tsc is run, of course. But it should resolve your chicken and egg problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With