Preact-cli: env: node\r: No such file or directory

Created on 17 Sep 2020  路  13Comments  路  Source: preactjs/preact-cli


Do you want to request a _feature_ or report a _bug_?

a bug.

What is the current behaviour?

When I run preact build in version 3.0.2 I'm receiving the error below:

env: node\r: No such file or directory

If the current behaviour is a bug, please provide the steps to reproduce.

  1. yarn add [email protected]
  2. yarn preact build

preact.config.js

https://gist.github.com/gabrielrtakeda/d9a2f75d91d5eb302295eb51eff8d104

What is the expected behaviour?

To build properly.

If this is a feature request, what is motivation or use case for changing the behaviour?

Please mention other relevant information.

Please paste the results of preact info here.

preact info in 3.0.2 also gives this error. Follow below the preact info using 3.0.1

Environment Info:
  System:
    OS: macOS 10.15.6
    CPU: (12) x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
  Binaries:
    Node: 14.11.0 - /var/folders/40/hmnm06wd6dv_q5pklkjdh5dc0000gn/T/yarn--1600377853618-0.2735555090153792/node
    Yarn: 1.22.5 - /var/folders/40/hmnm06wd6dv_q5pklkjdh5dc0000gn/T/yarn--1600377853618-0.2735555090153792/yarn
    npm: 6.14.8 - ~/.nvm/versions/node/v14.11.0/bin/npm
  Browsers:
    Chrome: 85.0.4183.102
    Firefox: 77.0.1
    Safari: 13.1.2
  npmPackages:
    preact: ^10.4.8 => 10.4.8
    preact-cli: ^3.0.1 => 3.0.1
    preact-render-to-string: ^5.1.10 => 5.1.10

Most helpful comment

published 3.0.3

All 13 comments

That's due the CRLF line endings on the latest deploy, sorry. It's been noted.

You can downgrade to v3.0.1 ("preact-cli": "3.0.1",) or do something along the lines of the following:

vim node_modules/preact-cli/lib/index.js

:se ff=unix
:wq

thanks for the quick reply... closing this

Don't have any actual power here to reopen this, but can you? It is a valid issue at the moment. Should stay open for visibility.

I'm getting the same error, and I'm on 3.0.1. preact build from command line works. yarn build gives the error.

In package.json:

  "scripts": {
    "build": "preact build",
    "serve": "sirv build --port 8080 --cors --single",
    "dev": "preact watch",
    "lint": "eslint src"
  },

@tuzmusic

Are you able to provide a repo? I'm willing to bet that you're not actually on 3.0.1, but 3.0.2. If you aren't aware, the symbols in a version number in you package.json decide which version upgrades you're okay with. ^ means you're fine with any changes to the patch version number, so 3.0.2 would fulfill ^3.0.0 or ^3.0.1. That's likely your issue.

Secondly, using preact build indicates you have the CLI globally installed, which is something we now recommend against. It's too easy for this to fall out of date and isn't really required. Instead we recommend using npx when you want to create new projects.

same here, what is the fix?

same here, what is the fix?

There is no fix :(
We have to wait for a 3.0.3 release.
If you correct the file (I used prettier --write) it'll just revert as soon as you do yarn install the next time.

Some investigation for this problem:

  • If you do a fresh install of preact-cli (version 3.0.2), all JS files will have windows CR LF line endings. This breaks the cli linux installations, since in /packages/cli/lib/index.js the following line can't be read by env:
#!/usr/bin/env node\r
  • The line endings in the source repository are correct LF endings, so not the culprit. (This can be confirmed by running file /packages/cli/lib/index.js:

Output from cloned git repo:

projects/preact-cli/packages/cli/lib/index.js: Node.js script, ASCII text executable

Output from downloaded npm zip:

index.js: Node.js script, ASCII text executable, with CRLF line terminators

Since I didn't find a automated CI/CD pipeline my guess would be: Someone, who is running windows, published manually and had core.autocrlf true set in his git config. This means the source repository was checked out with CRLF although they are LF

Yes, this was a problem specifically with the deploy. The editor config seemingly did not catch this.

@rschristian 馃憤

Can we expect a hotfix in the near future?

As of now I haven't heard anything. Until then downgrade to 3.0.1 or you can fix with the method I mentioned above.

I'll bring it back up.

Fix should be coming right up

published 3.0.3

Was this page helpful?
0 / 5 - 0 ratings