Skip to content
This repository was archived by the owner on Sep 12, 2019. It is now read-only.

npm not working in netlify.toml config #119

Closed
cj opened this issue Apr 11, 2019 · 4 comments
Closed

npm not working in netlify.toml config #119

cj opened this issue Apr 11, 2019 · 4 comments

Comments

@cj
Copy link

cj commented Apr 11, 2019

When I run netlify dev with the following netlify.toml:

[build]
  publish = "dist"
  command = "npm run build"
[dev]
  command = "npm run dev"
  port = 8080
  publish = "dist"

I get the following error:

Image 2019-04-11 at 1 57 41 PM

If I change it to use yarn it works:

[build]
  publish = "dist"
  command = "npm run build"
[dev]
  command = "yarn dev"
  port = 8080
  publish = "dist"

version: netlify-cli/2.11.7 darwin-x64 node-v11.12.0

@cj
Copy link
Author

cj commented Apr 11, 2019

Here is that log file:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/Cellar/node/11.12.0/bin/node',
1 verbose cli   '/usr/local/bin/npm',
1 verbose cli   'run',
1 verbose cli   'run',
1 verbose cli   'dev' ]
2 info using [email protected]
3 info using [email protected]
4 verbose stack Error: missing script: run
4 verbose stack     at run (/usr/local/lib/node_modules/npm/lib/run-script.js:155:19)
4 verbose stack     at /usr/local/lib/node_modules/npm/lib/run-script.js:63:5
4 verbose stack     at /usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:115:5
4 verbose stack     at /usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:418:5
4 verbose stack     at checkBinReferences_ (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:373:45)
4 verbose stack     at final (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:416:3)
4 verbose stack     at then (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:160:5)
4 verbose stack     at /usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:364:12
4 verbose stack     at /usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:90:16
4 verbose stack     at FSReqCallback.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:54:3)
5 verbose cwd /Users/cj/apps/yah/pika/yah
6 verbose Darwin 18.5.0
7 verbose argv "/usr/local/Cellar/node/11.12.0/bin/node" "/usr/local/bin/npm" "run" "run" "dev"
8 verbose node v11.12.0
9 verbose npm  v6.7.0
10 error missing script: run
11 verbose exit [ 1, true ]

@shortdiv
Copy link
Contributor

The plugin might be having issues with the way you're specifying the build in the dev block. Because of the way the plugin is implemented, the build command should be written [npm/yarn] [build script].

So try

[dev]
  command = "npm dev"

instead of

[dev]
  command = "npm run dev"

@cj
Copy link
Author

cj commented Apr 11, 2019

@shortdiv thanks for the reply!

That does work, however, I think it's still a bug. npm dev from the command line is not valid and the [build] option lets you write command = "npm run build" which works and is correct.

@shortdiv
Copy link
Contributor

Good point! Do you want to submit a PR to fix this? :) Happy to offer guidance if you're interested!

@swyxio swyxio closed this as completed in 8e108a3 May 3, 2019
swyxio added a commit that referenced this issue May 3, 2019
Fix dev command when running with npm - fix #119
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants